Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#085 auto_merge_approved_pr.yml 오류 수정 #92

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
Loading