-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: 2명 이상이 approve한 PR을 자동으로 merge하는 workflow 추가
- Loading branch information
1 parent
d5bd75a
commit 7dd1d35
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: "Auto Merge Approved PRs" | ||
|
||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
jobs: | ||
auto_merge: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Get Pull Request" | ||
id: pr | ||
uses: actions/github-script@v6 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const { data: pr } = await github.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.payload.pull_request.number, | ||
}); | ||
return JSON.stringify(pr); | ||
- name: "Check Approvals" | ||
id: check | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const pr = JSON.parse(steps.pr.outputs.result); | ||
const reviews = await github.pulls.listReviews({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pr.number, | ||
}); | ||
const approvals = reviews.data.filter(review => review.state === 'APPROVED'); | ||
return approvals.length >= 2; | ||
- name: "Merge PR" | ||
if: steps.check.outputs.result == 'true' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
await github.pulls.merge({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.payload.pull_request.number, | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ on: | |
- dev | ||
|
||
jobs: | ||
lint-and-test: | ||
lint_and_test: | ||
name: Lint and Test | ||
runs-on: ubuntu-latest | ||
|
||
|