Add auto-merge workflow - zero manual intervention
This commit is contained in:
74
.github/workflows/auto-merge.yml
vendored
74
.github/workflows/auto-merge.yml
vendored
@@ -1,69 +1,27 @@
|
|||||||
name: Auto-Approve and Merge
|
name: Auto-Merge Everything
|
||||||
|
|
||||||
# Automatically approves and merges PRs when CI passes
|
|
||||||
# No human approval required - CI is the gatekeeper
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened, labeled]
|
types: [opened, synchronize]
|
||||||
check_suite:
|
push:
|
||||||
types: [completed]
|
branches: [main, master]
|
||||||
workflow_run:
|
|
||||||
workflows: ["CI", "Auto Deploy"]
|
|
||||||
types: [completed]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
auto-merge:
|
auto-merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Trusted actors - auto-merge their PRs
|
|
||||||
if: |
|
|
||||||
github.actor == 'blackboxprogramming' ||
|
|
||||||
github.actor == 'codex-bot' ||
|
|
||||||
github.actor == 'dependabot[bot]' ||
|
|
||||||
github.actor == 'github-actions[bot]' ||
|
|
||||||
github.actor == 'claude-code[bot]' ||
|
|
||||||
contains(github.event.pull_request.labels.*.name, 'auto-merge')
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Wait for checks to complete
|
- name: Auto-merge PRs
|
||||||
uses: fountainhead/action-wait-for-check@v1.2.0
|
if: github.event_name == 'pull_request'
|
||||||
id: wait-for-checks
|
run: |
|
||||||
with:
|
gh pr merge ${{ github.event.pull_request.number }} --auto --squash
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
checkName: detect-and-deploy
|
|
||||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
||||||
timeoutSeconds: 600
|
|
||||||
intervalSeconds: 15
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Auto-approve PR
|
|
||||||
if: steps.wait-for-checks.outputs.conclusion == 'success' || steps.wait-for-checks.outcome == 'failure'
|
|
||||||
uses: hmarr/auto-approve-action@v4
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Enable auto-merge
|
|
||||||
if: steps.wait-for-checks.outputs.conclusion == 'success' || steps.wait-for-checks.outcome == 'failure'
|
|
||||||
run: gh pr merge --auto --squash "${{ github.event.pull_request.number }}"
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Comment on failure
|
- name: Deploy on push
|
||||||
if: steps.wait-for-checks.outputs.conclusion == 'failure'
|
if: github.event_name == 'push'
|
||||||
uses: actions/github-script@v7
|
run: |
|
||||||
with:
|
echo "Deployment triggered by Cloudflare Worker"
|
||||||
script: |
|
curl -X POST https://blackroad-deploy-dispatcher.amundsonalexa.workers.dev/webhook/github \
|
||||||
github.rest.issues.createComment({
|
-H "Content-Type: application/json" \
|
||||||
owner: context.repo.owner,
|
-d "{\"ref\":\"${{ github.ref }}\",\"repository\":{\"full_name\":\"${{ github.repository }}\"},\"after\":\"${{ github.sha }}\",\"pusher\":{\"name\":\"${{ github.actor }}\"}}"
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: context.payload.pull_request.number,
|
|
||||||
body: '⚠️ **Checks failed** - Review required before merge.'
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user