From 5e8d7f56a6ac8e8ffaf2467a7a39f0fc4392bb76 Mon Sep 17 00:00:00 2001 From: mxsm Date: Sat, 15 Jun 2024 22:52:03 +0800 Subject: [PATCH] Update label-on-approval.yml --- .github/workflows/label-on-approval.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/label-on-approval.yml b/.github/workflows/label-on-approval.yml index b4e49235..525a06b7 100644 --- a/.github/workflows/label-on-approval.yml +++ b/.github/workflows/label-on-approval.yml @@ -2,7 +2,11 @@ name: Add Label on Approval on: pull_request_review: - types: [ submitted,edited ] + types: [submitted] + +permissions: + issues: write + pull-requests: write jobs: add-label: @@ -15,14 +19,15 @@ jobs: - name: Check if approval is from Collaborators id: check_approval uses: actions/github-script@v7 - env: - GITHUB_TOKEN: "${{ secrets.PAT }}" with: - github-token: ${{ evn.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { owner, repo } = context.repo; const { pull_request, review } = context.payload; - + if (!review) { + console.log('No review found.'); + return; + } // Define your list of collaborators const collaborators = ['mxsm', 'TeslaRustor','SpaceXCN']; // Replace with actual GitHub usernames console.log('review:', review.state);