Files
hassio-addons/.github/workflows/onpr_automerge.yaml
2024-06-17 12:46:47 +02:00

40 lines
1.1 KiB
YAML

# yamllint disable rule:line-length
# shellcheck disable=SC2043
---
name: Automerge PRs
on:
issue_comment:
types:
- created
jobs:
automerge:
runs-on: ubuntu-latest
steps:
- name: Check if comment contains "/automerge"
id: check_comment
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const comment = context.payload.comment.body;
return { automerge: comment.includes('/automerge') };
- name: Merge PR
if: steps.check_comment.outputs.automerge
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
await github.pulls.merge({
owner,
repo,
pull_number: prNumber,
merge_method: 'merge'
});
console.log(`PR #${prNumber} merged successfully.`);