Skip to content

Automerge

Automerge #477

name: Automerge
on:
status:
jobs:
automerge-flathubbot-prs:
runs-on: ubuntu-latest
if: github.event.state == 'success'
steps:
- uses: actions/github-script@v7
with:
script: |
commit_author = context.payload.commit.author.login
if (commit_author == 'flathubbot'){
// Since the status update is for a commit not a pull request, we need to find the corresponding PR.
// We do this by iterating on all open PRs until we find one where the head ref is the same as the payload branch
const result = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open"
});
for (const pr of result.data) {
if (pr.head.ref == context.payload.branches[0].name)
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number
});
}
}