-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "[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' | ||
|
@@ -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 |