From 804399f949df90fdb31e9526f796ca18778475d7 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Mon, 11 Nov 2024 10:29:05 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20audo=5Fmerge=5Fapprove=5Fpr.yml=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto_merge_approved_pr.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml index 2870bbf7..3c755913 100644 --- a/.github/workflows/auto_merge_approved_pr.yml +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -12,9 +12,10 @@ jobs: id: pr uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} result-encoding: string script: | - const { data: pr } = await github.pulls.get({ + const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number, @@ -24,21 +25,23 @@ jobs: id: check uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const pr = JSON.parse(steps.pr.outputs.result); - const reviews = await github.pulls.listReviews({ + const reviews = await github.rest.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; + core.setOutput('result', approvals.length >= 2); - name: "Merge PR" - if: steps.check.outputs.result == 'true' + if: steps.check.outputs.result uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | - await github.pulls.merge({ + await github.rest.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number,