Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

name: Lint
on: [push, pull_request]
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
- run: |
echo "No lint checks";
exit 1;
shellcheck sync-files/admin-approve-merge.sh
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@

name: Test
on: [push, pull_request]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
persist-credentials: false
- run: |
echo "No tests";
exit 1;
bash -n sync-files/admin-approve-merge.sh
65 changes: 59 additions & 6 deletions sync-files/admin-approve-merge.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,62 @@
gh search repos --owner googleworkspace --archived=false --json name --limit 200 -q '.[].name' | while read -r repo; do
gh pr list --repo "googleworkspace/$repo" \
--search "is:pr is:open \"chore: Synced file(s) with googleworkspace/.github\"" \
--json url --jq '.[].url' | while read -r pr_url; do
#!/bin/bash
# Copyright 2026 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.

set -euo pipefail

EXPECTED_TITLE="chore: Synced file(s) with googleworkspace/.github"
EXPECTED_AUTHOR="googleworkspace-bot"
EXPECTED_OWNER="googleworkspace"
EXPECTED_LABEL="sync-files"
EXPECTED_BRANCH_PREFIX="sync-files-"

gh search repos --owner "$EXPECTED_OWNER" --archived=false --json name --limit 200 -q '.[].name' | while read -r repo; do
gh pr list --repo "$EXPECTED_OWNER/$repo" \
--state open \
--author "$EXPECTED_AUTHOR" \
--label "$EXPECTED_LABEL" \
--json url,title,author,isCrossRepository,headRepositoryOwner,headRefName,labels \
--jq '.[] | select(
.author.login == "'"$EXPECTED_AUTHOR"'" and
.isCrossRepository == false and
.headRepositoryOwner.login == "'"$EXPECTED_OWNER"'" and
(.headRefName | startswith("'"$EXPECTED_BRANCH_PREFIX"'")) and
.title == "'"$EXPECTED_TITLE"'" and
any(.labels[]; .name == "'"$EXPECTED_LABEL"'")
) | .url' | while read -r pr_url; do
[ -z "$pr_url" ] && continue

# Re-verify PR metadata via gh pr view before taking privileged action
verified_title="$(gh pr view "$pr_url" \
--json title,state,author,isCrossRepository,headRepositoryOwner,headRefName,labels \
--jq 'select(
.state == "OPEN" and
.author.login == "'"$EXPECTED_AUTHOR"'" and
.isCrossRepository == false and
.headRepositoryOwner.login == "'"$EXPECTED_OWNER"'" and
(.headRefName | startswith("'"$EXPECTED_BRANCH_PREFIX"'")) and
.title == "'"$EXPECTED_TITLE"'" and
any(.labels[]; .name == "'"$EXPECTED_LABEL"'")
) | .title')"

if [ "$verified_title" != "$EXPECTED_TITLE" ]; then
echo "Skipping unverified PR $pr_url" >&2
continue
fi

echo "Processing $pr_url..."
gh pr review "$pr_url" --approve </dev/null
gh pr merge "$pr_url" --admin --squash --subject "$(gh pr view "$pr_url" --json title --jq .title)" </dev/null
gh pr merge "$pr_url" --admin --squash --subject "$verified_title" </dev/null
done
done
done
Loading