-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automerge every 15-min any PR with passing tests labeled with 'autome…
…rge'
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Auto-merge Successful PRs | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "*/15 * * * *" # Every 15 minutes | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
find_and_merge: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@v2 | ||
with: | ||
egress-policy: audit | ||
- name: Checking out repo | ||
uses: actions/checkout@v4 | ||
|
||
# Fetch open pull requests and check for status checks on automerge PRs | ||
- name: Auto-merge pull requests if all status checks pass | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.DEPLOY_KEY_TO_UPDATE_STRICT_BRANCH }} | ||
run: | | ||
build-scripts/hack/auto-merge-successful-prs.sh |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Fetch the open pull requests | ||
prs=$(gh pr list --state open --json number,headRefName,labels | jq '[.[] | select(.labels | any(.name == "automerge"))]') | ||
|
||
for pr in $(echo "$prs" | jq -r '.[] | @base64'); do | ||
_jq() { | ||
echo ${pr} | base64 --decode | jq -r ${1} | ||
} | ||
|
||
pr_number=$(_jq '.number') | ||
head_branch=$(_jq '.headRefName') | ||
|
||
# Check status checks for each PR | ||
checks_passed=$(gh pr checks $pr_number --json bucket | jq -r '.[].bucket == "pass"' | sort | uniq) | ||
|
||
if [[ "$checks_passed" == "true" ]]; then | ||
echo "All status checks passed for PR #$pr_number. Proceeding with merge..." | ||
gh pr merge $pr_number --auto --squash | ||
else | ||
echo "Status checks have not passed for PR #$pr_number. Skipping merge." | ||
fi | ||
done |