diff --git a/.github/workflows/raise-pr-for-constants.yml b/.github/workflows/raise-pr-for-constants.yml index b17cfed17..c56ff3896 100644 --- a/.github/workflows/raise-pr-for-constants.yml +++ b/.github/workflows/raise-pr-for-constants.yml @@ -11,6 +11,8 @@ permissions: env: BRANCH_NAME: chore/gh-update-destinations-ts + SRC_FILE: generated/Destinations.ts + DEST_PATH: packages/analytics-js-common/src/constants/integrations/Destinations.ts jobs: check_changes: @@ -26,28 +28,25 @@ jobs: - name: Checkout Destination Repo run: | DEST_REPO="rudderlabs/rudder-sdk-js" - git clone https://github.com/${DEST_REPO}.git dest-repo + git clone https://github.com/${DEST_REPO}.git dest-repo || exit 1 cd dest-repo git config --global user.name "GitHub Actions" git config --global user.email "noreply@github.com" git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/" git checkout -b ${{ env.BRANCH_NAME }} - git pull origin ${{ env.BRANCH_NAME }} || echo "No updates to pull" - + git pull origin ${{ env.BRANCH_NAME }} || true + - name: Compare Destinations.ts id: compare_files run: | - SRC_FILE="generated/Destinations.ts" - DEST_REPO="rudderlabs/rudder-sdk-js" - DEST_PATH="packages/analytics-js-common/src/constants/integrations/Destinations.ts" - - if cmp -s "$SRC_FILE" "dest-repo/$DEST_PATH"; then + if cmp -s "${{ env.SRC_FILE }}" "dest-repo/${{ env.DEST_PATH }}"; then echo "No changes detected." > result.txt echo "pr_required=false" >> $GITHUB_OUTPUT else echo "Changes detected." > result.txt echo "pr_required=true" >> $GITHUB_OUTPUT fi + raise_pr: needs: check_changes if: needs.check_changes.outputs.pr_required == 'true' @@ -62,6 +61,8 @@ jobs: git push origin ${{ env.BRANCH_NAME }} - name: Create or Update PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | cd dest-repo EXISTING_PR=$(gh pr list --head ${{ env.BRANCH_NAME }} --json number --jq ".[0].number")