Skip to content

Commit 99c0067

Browse files
committed
feat: Creates two new workflow actions for merging dist.
1 parent 9589832 commit 99c0067

File tree

3 files changed

+92
-27
lines changed

3 files changed

+92
-27
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Approve and Merge Release Pull Request
16+
17+
on:
18+
pull_request_target:
19+
types:
20+
- opened
21+
- synchronize
22+
- reopened
23+
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/**'
27+
28+
jobs:
29+
approve-and-merge:
30+
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'
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v3
35+
with:
36+
ref: ${{ github.event.pull_request.head.sha }} # Checkout the PR's head commit
37+
token: ${{ secrets.GH_TOKEN_RELEASE }}
38+
39+
- name: Approve PR
40+
run: gh pr review --approve "$PR_URL"
41+
env:
42+
PR_URL: ${{ github.event.pull_request.html_url }}
43+
GH_TOKEN: ${{ secrets.GH_TOKEN_RELEASE }}
44+
45+
- name: Merge PR
46+
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
47+
env:
48+
PR_URL: ${{ github.event.pull_request.html_url }}
49+
GH_TOKEN: ${{ secrets.GH_TOKEN_RELEASE }}

.github/workflows/dist-pr.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Create release PR for dist
16+
17+
on:
18+
push:
19+
branches:
20+
- dist
21+
22+
jobs:
23+
create-pr:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v3
28+
with:
29+
ref: ${{ github.event.after }} # Check out the *new* commit on dist
30+
31+
- name: Create Pull Request
32+
uses: peter-evans/create-pull-request@v5
33+
with:
34+
token: ${{ secrets.GH_TOKEN_RELEASE }}
35+
commit-message: 'chore: automated output update (dist)'
36+
title: 'chore: automated output update (dist)'
37+
body: 'This PR contains updated build output from the dist branch.'
38+
branch: 'dist-to-main-pr' # Use a dedicated PR branch
39+
base: main
40+
labels: |
41+
automated pr
42+
dist-update
43+
draft: false # Or true, if you want to review before enabling auto-merge

.github/workflows/release.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,36 +92,9 @@ jobs:
9292
- name: Add and commit changes to the dist folder
9393
run: |
9494
git add dist
95-
git add index.html
9695
if [[ -n $(git status --porcelain) ]]; then
9796
git commit -m "Update dist folder"
9897
git push origin dist
9998
else
10099
echo "No changes to commit"
101100
fi
102-
103-
- name: debugging steps
104-
run: |
105-
echo "github.ref is ${{ github.ref }}"
106-
echo "github.actor is ${{ github.actor }}"
107-
108-
approve-and-merge:
109-
runs-on: ubuntu-latest
110-
if: ${{ github.event_name == 'workflow_dispatch' && github.actor == 'googlemaps-bot[bot]' }}
111-
env:
112-
PR_URL: ${{ github.event.pull_request.html_url }}
113-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114-
steps:
115-
- name: Checkout code
116-
uses: actions/checkout@v3
117-
118-
- name: Create Pull Request
119-
id: cpr
120-
run: |
121-
echo "pull_request_url=$(gh pr create --title 'chore: automated output update (dist)' --body 'This PR contains updated build output from the dist branch.' --base main --head dist)" >> $GITHUB_OUTPUT
122-
123-
- name: Approve PR
124-
run: gh pr review --approve ${{ steps.cpr.outputs.pull_request_url }}
125-
126-
- name: Merge PR
127-
run: gh pr merge --auto --squash --delete-branch ${{ steps.cpr.outputs.pull_request_url }}

0 commit comments

Comments
 (0)