Skip to content

Commit

Permalink
ci: add reusable merger workflow (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored Jul 11, 2022
1 parent 05b4431 commit d824695
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/merger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pull-request Merger

on:
workflow_call:
issue_comment:
types: [created, edited]

jobs:
merge:
if: |
(github.event.issue.pull_request) &&
(github.event.comment.author_association == 'OWNER') &&
(github.event.comment.body == '/merge')
runs-on: ubuntu-20.04
timeout-minutes: 1
permissions:
contents: write
pull-requests: write
steps:
- name: Merge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUM: ${{ github.event.issue.number }}
run: |
PR_JSON=$(gh pr view "${PR_NUM}" --json "title,body,labels" --repo "${GITHUB_REPOSITORY}")
PR_TITLE=$(echo "${PR_JSON}" | jq -r '.title')
PR_BODY=$(echo "${PR_JSON}" | jq -r '.body')
PR_LABELS=$(echo "${PR_JSON}" | jq -r '.labels[].name' | sed "s/^/- /g")
PR_MERGE_TITLE="${PR_TITLE} (#${PR_NUM})"
gh pr merge "${PR_NUM}" --squash \
--subject "${PR_MERGE_TITLE}" \
--repo "${GITHUB_REPOSITORY}" \
--body "${PR_BODY}
Labels:
${PR_LABELS}"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,19 @@ jobs:
hadolint:
uses: peaceiris/workflows/.github/workflows/hadolint.yml@v0.14.0
```



## Reusable pull-request merger workflow

```yaml
name: pull-request
on:
issue_comment:
types: [created, edited]
jobs:
merger:
uses: peaceiris/workflows/.github/workflows/merger.yml@v0.16.0
```

0 comments on commit d824695

Please sign in to comment.