Skip to content

Commit

Permalink
Merge pull request #92 from boostcampwm-2024/Feature/#085_Github_Acti…
Browse files Browse the repository at this point in the history
…ons_설정

Feature/#85 auto_merge_approved_pr.yml 오류 수정
  • Loading branch information
hyonun321 authored Nov 11, 2024
2 parents 05e6b0b + 520cce1 commit 9b4b32e
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/auto_merge_approved_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,30 @@ jobs:
auto_merge:
runs-on: ubuntu-latest
steps:
- name: "Get Pull Request"
id: pr
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { data: pr } = await github.rest.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:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const pr = JSON.parse(steps.pr.outputs.result);
const pull_number = context.payload.pull_request.number;
const reviews = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
pull_number: pull_number,
});
const approvals = reviews.data.filter(review => review.state === 'APPROVED');
core.setOutput('result', approvals.length >= 2);
return approvals.length >= 2;
- name: "Merge PR"
if: steps.check.outputs.result
if: ${{ steps.check.outputs.result == 'true' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pull_number = context.payload.pull_request.number;
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
pull_number: pull_number,
});

0 comments on commit 9b4b32e

Please sign in to comment.