Automerge #490
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
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 | |
}); | |
} | |
} |