Update onpr_automerge.yaml

This commit is contained in:
Alexandre
2024-06-17 12:46:47 +02:00
committed by GitHub
parent 79fbd84fc9
commit f3b51997db

View File

@@ -1,43 +1,39 @@
# yamllint disable rule:line-length
# shellcheck disable=SC2043
---
name: automerge
name: Automerge PRs
on:
pull_request_review:
types:
- submitted
issue_comment:
types: created
check_suite:
types:
- completed
status: {}
- created
jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Add the automerge label
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/automerge') }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['automerge']
})
automerge:
runs-on: ubuntu-latest
needs: [labeler]
steps:
- id: automerge
if: ${{ github.event.issue.pull_request }}
name: automerge
uses: "pascalgn/automerge-action@v0.16.2"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Build:
needs: automerge
uses: ./.github/workflows/onpush_builder.yaml
- 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.`);