diff --git a/.github/workflows/publish-components.yaml b/.github/workflows/publish-components.yaml index 707b253d10bba..c1862ff20d5b0 100644 --- a/.github/workflows/publish-components.yaml +++ b/.github/workflows/publish-components.yaml @@ -1,7 +1,7 @@ on: push: branches: - - master + - publish-test jobs: publish-components: @@ -26,21 +26,40 @@ jobs: - name: Publish and add to registry components/*.js (that aren't .app.js files) env: PD_API_KEY: ${{ secrets.PD_API_KEY }} + shell: bash {0} # don't fast fail run: | + UNPUBLISHED=() mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}') for added_modified_file in "${added_modified_files[@]}"; do # starts with components, ends with .js and not app.js if [[ $added_modified_file == components/* ]] && [[ $added_modified_file == *.js ]] && [[ $added_modified_file != *.app.js ]] then echo "attempting to publish ${added_modified_file}" - KEY=`./pd publish ${added_modified_file} --json | jq -r ".key"` - echo "published ${KEY}" - echo "${KEY} will be added to the registry" - curl "https://api.pipedream.com/graphql" -H "Content-Type: application/json" -H "Authorization: Bearer ${PD_API_KEY}" --data-binary $'{"query":"mutation($key: String\u0021, $registry: Boolean\u0021){\\n setComponentRegistry(key: $key, registry: $registry){\\n savedComponent{\\n id\\n key\\n }\\n }\\n}","variables":{"key":"'${KEY}'","registry":'true'}}' + PD_OUTPUT=`./pd publish ${added_modified_file} --json` + if [ $? -eq 0 ] + then + echo $PD_OUTPUT + KEY=`echo $PD_OUTPUT | jq -r ".key"` + echo $KEY + echo "published ${KEY}" + echo "${KEY} will be added to the registry" + CURL_OUTPUT=`curl "https://api.pipedream.com/graphql" -H "Content-Type: application/json" -H "Authorization: Bearer ${PD_API_KEY}" --data-binary $'{"query":"mutation($key: String\u0021, $registry: Boolean\u0021){\\n setComponentRegistry(key: $key, registry: $registry){\\n savedComponent{\\n id\\n key\\n }\\n }\\n}","variables":{"key":"'${KEY}'","registry":'true'}}'` + echo $CURL_OUTPUT + else + ERROR=`echo $PD_OUTPUT | jq -r ".error"` + echo "there was an error: ${ERROR} with ${added_modified_file}" + UNPUBLISHED+=${added_modified_file} + # add to array to spit out later + fi else echo "${added_modified_file} will not be added to the registry" fi done + # print out everything that didn't publish + if [ ${#UNPUBLISHED[@]} -ne 0 ]; then + echo "the following files were not published" + printf '%s\n' "${UNPUBLISHED[@]}" + fi - name: Remove pd cli config run: | rm $HOME/.config/pipedream/config