Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/approve-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Approve and Merge Release Pull Request

on:
pull_request_target:
types:
- opened
- synchronize
- reopened
branches:
- main # Only trigger for PRs targeting main
paths: # Optional but recommended: only trigger for changes in specific parts of the repo
- 'dist/**'

jobs:
approve-and-merge:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'googlemaps-bot[bot]' && github.event.pull_request.head.ref == 'dist-to-main-pr'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # Checkout the PR's head commit
token: ${{ secrets.GH_TOKEN_RELEASE }}

- name: Approve PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN_RELEASE }}

- name: Merge PR
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GH_TOKEN_RELEASE }}
43 changes: 43 additions & 0 deletions .github/workflows/dist-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Create release PR for dist

on:
push:
branches:
- dist

jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.after }} # Check out the *new* commit on dist

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GH_TOKEN_RELEASE }}
commit-message: 'chore: automated output update (dist)'
title: 'chore: automated output update (dist)'
body: 'This PR contains updated build output from the dist branch.'
branch: 'dist-to-main-pr' # Use a dedicated PR branch
base: main
labels: |
automated pr
dist-update
draft: false # Or true, if you want to review before enabling auto-merge
27 changes: 0 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,9 @@ jobs:
- name: Add and commit changes to the dist folder
run: |
git add dist
git add index.html
if [[ -n $(git status --porcelain) ]]; then
git commit -m "Update dist folder"
git push origin dist
else
echo "No changes to commit"
fi

- name: debugging steps
run: |
echo "github.ref is ${{ github.ref }}"
echo "github.actor is ${{ github.actor }}"

approve-and-merge:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' && github.actor == 'googlemaps-bot[bot]' }}
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Create Pull Request
id: cpr
run: |
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

- name: Approve PR
run: gh pr review --approve ${{ steps.cpr.outputs.pull_request_url }}

- name: Merge PR
run: gh pr merge --auto --squash --delete-branch ${{ steps.cpr.outputs.pull_request_url }}