diff --git a/.github/workflows/check-generated.yml b/.github/workflows/check-generated.yml index fbba03691..d8c40f7ac 100644 --- a/.github/workflows/check-generated.yml +++ b/.github/workflows/check-generated.yml @@ -33,7 +33,7 @@ jobs: if [ -n "$(git status --porcelain)" ]; then echo "::error::Generated constants are not up-to-date. Run 'npm run generate:constants' and commit the changes."; echo "Here are the differences:"; - git diff; + git diff || true 2>&1; exit 1; else echo "Git state is clean."; diff --git a/.github/workflows/raise-pr-for-constants.yml b/.github/workflows/raise-pr-for-constants.yml index b17cfed17..f088ca122 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 - echo "No changes detected." > result.txt + 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 "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,11 +61,21 @@ 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") if [ -z "$EXISTING_PR" ]; then - gh pr create -f + gh pr create \ + --title "chore: update destination constants" \ + --body "This PR updates the destination constants file. + + **Changes:** + - Updated \`Destinations.ts\` with latest constants + + This PR was automatically generated by GitHub Actions." \ + --label "automated,dependencies" else echo "PR already exists: $EXISTING_PR" fi