Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Dec 10, 2024
1 parent 9847825 commit 993b522
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/raise-pr-for-constants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 "[email protected]"
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'
Expand All @@ -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

0 comments on commit 993b522

Please sign in to comment.