File tree Expand file tree Collapse file tree 3 files changed +20
-23
lines changed
Expand file tree Collapse file tree 3 files changed +20
-23
lines changed Original file line number Diff line number Diff line change 2121 - synchronize
2222 - reopened
2323 branches :
24- - main # Only trigger for PRs targeting main
25- paths : # Optional but recommended: only trigger for changes in specific parts of the repo
26- - ' dist/**'
24+ - main
2725
2826jobs :
2927 approve-and-merge :
3028 runs-on : ubuntu-latest
31- if : github.event.pull_request.user.login == 'googlemaps-bot[bot]' && github.event.pull_request.head.ref == 'dist-to-main-pr'
29+ if : github.event.pull_request.user.login == 'googlemaps-bot[bot]' && github.event.pull_request.head.ref == 'temp-build-branch' # change here
3230 steps :
3331 - name : Checkout code
3432 uses : actions/checkout@v3
3533 with :
36- ref : ${{ github.event.pull_request.head.sha }} # Checkout the PR's head commit
34+ ref : ${{ github.event.pull_request.head.ref }} # Checkout the PR's head commit
3735 token : ${{ secrets.GH_MERGE_TOKEN }}
3836
3937 - name : Approve PR
Original file line number Diff line number Diff line change @@ -34,18 +34,23 @@ jobs:
3434 git config --global user.name 'googlemaps-bot'
3535 git config --global user.email '[email protected] ' 3636
37- - name : Create Branch for PR
38- run : |
39- git fetch origin main
40- git checkout -b dist-to-main-pr origin/dist
41-
4237 - name : Create Pull Request
4338 run : |
4439 gh pr create \
4540 --base main \
46- --head dist-to-main-pr \
41+ --head temp-build-branch \
4742 --title "chore: automated output update (dist)" \
4843 --body "This PR contains updated build output from the dist branch." \
4944 --label "automated pr,dist-update"
45+ env :
46+ GH_TOKEN : ${{ secrets.GH_MERGE_TOKEN }}
47+
48+ - name : Check for Existing PR and Close (Optional)
49+ run : |
50+ EXISTING_PR=$(gh pr list --base main --head temp-build-branch --state open --json number -q '.[].number')
51+ if [[ -n "$EXISTING_PR" ]]; then
52+ echo "Found existing open PR(s) for temp-build-branch: $EXISTING_PR"
53+ gh pr close "$EXISTING_PR"
54+ fi
5055 env :
5156 GH_TOKEN : ${{ secrets.GH_MERGE_TOKEN }}
Original file line number Diff line number Diff line change 3131 - name : Checkout main
3232 uses : actions/checkout@v3
3333 with :
34- ref : main # Checkout *main* initially
34+ ref : main
3535 token : ${{ secrets.GH_MERGE_TOKEN }}
3636 fetch-depth : 0
3737
@@ -64,17 +64,11 @@ jobs:
6464 - name : Deploy to Firebase Hosting
6565 run : firebase deploy --only hosting
6666
67- - name : Checkout dist branch
68- run : git checkout -B dist origin/dist || git checkout -b dist
67+ - name : Create temporary branch
68+ run : git checkout -b temp-build-branch
6969
70- - name : Prepare dist folder
70+ - name : Commit and Push Changes (to temp branch)
7171 run : |
72- rm -rf samples
73- mkdir -p dist
74- cp -r ./dist/* ./dist/
75-
76- - name : Commit and Push Changes (to dist)
77- run : |
78- git add .
72+ git add dist
7973 git commit -m "Update dist folder"
80- git push --force origin dist
74+ git push --force origin temp-build-branch
You can’t perform that action at this time.
0 commit comments