From 9b046caf317571ea8abf05d80886d1508c70ef07 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Mon, 11 Nov 2024 17:18:23 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20auto=5Fmerge=5Fapprove=5Fpr.yml=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml index 3c755913..0cfbdefa 100644 --- a/.github/workflows/auto_merge_approved_pr.yml +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -20,14 +20,14 @@ jobs: repo: context.repo.repo, pull_number: context.payload.pull_request.number, }); - return JSON.stringify(pr); + core.setOutput('result', JSON.stringify(pr)); - name: "Check Approvals" id: check uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const pr = JSON.parse(steps.pr.outputs.result); + const pr = JSON.parse(`${{ steps.pr.outputs.result }}`); const reviews = await github.rest.pulls.listReviews({ owner: context.repo.owner, repo: context.repo.repo, @@ -36,7 +36,7 @@ jobs: const approvals = reviews.data.filter(review => review.state === 'APPROVED'); core.setOutput('result', 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 }} From a121df751f3dae9fe7e31a9a80a9207ee79047a7 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Mon, 11 Nov 2024 17:43:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20auto=5Fmerge=5Fapprove=5Fpr.yml?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=B6=9C=EB=A0=A5=EC=9D=84=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B3=80=EC=88=98=EB=A1=9C=20=EC=A0=84=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #085 --- .github/workflows/auto_merge_approved_pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml index 0cfbdefa..a8be7d89 100644 --- a/.github/workflows/auto_merge_approved_pr.yml +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -24,10 +24,12 @@ jobs: - name: "Check Approvals" id: check uses: actions/github-script@v6 + env: + PR_RESULT: ${{ steps.pr.outputs.result }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const pr = JSON.parse(`${{ steps.pr.outputs.result }}`); + const pr = JSON.parse(process.env.PR_RESULT); const reviews = await github.rest.pulls.listReviews({ owner: context.repo.owner, repo: context.repo.repo, From 520cce138ed82b431746396b5accebaaf486d308 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Mon, 11 Nov 2024 18:26:14 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=8A=A4=ED=83=AD=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=ED=86=B5=ED=95=A9,=20core.setOutput=EC=9D=84=20ret?= =?UTF-8?q?urn=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #085 --- .github/workflows/auto_merge_approved_pr.yml | 25 +++++--------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml index a8be7d89..39e73f5c 100644 --- a/.github/workflows/auto_merge_approved_pr.yml +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -8,43 +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, - }); - core.setOutput('result', JSON.stringify(pr)); - name: "Check Approvals" id: check uses: actions/github-script@v6 - env: - PR_RESULT: ${{ steps.pr.outputs.result }} with: github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string script: | - const pr = JSON.parse(process.env.PR_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 == '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, });