Skip to content

Disable auto-merge #2582

Disable auto-merge

Disable auto-merge #2582

name: Disable auto-merge
on:
workflow_run:
workflows:
- CI
types:
- completed
permissions:
pull-requests: write
contents: write
jobs:
Run:
runs-on: ubuntu-latest
# pull_request or pull_request_target initiated by dependabot
if: ${{ startsWith(github.event.workflow_run.event, 'pull_request') &&
github.event.workflow.pull_requests[0].auto_merge != null &&
contains(github.event.pull_requests[0].labels.*.name, 'dependencies') }}
steps:
- id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: PR number
run: echo "$PR_NUMBER"
env:
PR_NUMBER: ${{ github.event.workflow.pull_requests[0].number }}
- name: Remove automerge
if: ${{ github.event.workflow.conclusion != 'success' }}
run: |
gh pr merge --disable-auto "$PR_NUMBER"
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
PR_NUMBER: ${{ github.event.workflow.pull_requests[0].number }}