From 6d4354d02f19ddcec623d19f866f5595ac17ba44 Mon Sep 17 00:00:00 2001 From: Felipe Peter Date: Tue, 9 Jan 2024 17:19:36 +0100 Subject: [PATCH] ci: Auto-approve on PR review Fixes a bug introduced during the upgrade to node.js 20 and now also approves PRs that have been reviewed with an `LGTM` comment. --- .github/workflows/auto_approve.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto_approve.yml b/.github/workflows/auto_approve.yml index 4a729d0..ac962ac 100644 --- a/.github/workflows/auto_approve.yml +++ b/.github/workflows/auto_approve.yml @@ -3,14 +3,23 @@ name: Auto-Approve on: issue_comment: types: [created] + pull_request_review: + types: [submitted] jobs: auto-approve: runs-on: ubuntu-latest if: | - github.event.issue.pull_request != '' + ( + github.event_name == 'issue_comment' + && github.event.issue.pull_request != '' && github.event.comment.user.login == 'Mr-Pepe' && contains(github.event.comment.body, 'LGTM') + ) || ( + github.event_name == 'pull_request_review' + && github.event.review.user.login == 'Mr-Pepe' + && github.event.review.body == 'LGTM' + ) permissions: pull-requests: write steps: @@ -18,7 +27,7 @@ jobs: uses: actions/github-script@v7 with: script: | - await github.pulls.createReview({ + await github.rest.pulls.createReview({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number,