diff --git a/.github/workflows/update-labels.yml b/.github/workflows/update-labels.yml index 262604f23cf0..85475007d35c 100644 --- a/.github/workflows/update-labels.yml +++ b/.github/workflows/update-labels.yml @@ -1,19 +1,21 @@ -name: Update label when user responds +name: Update labels when user responds in issue and pr permissions: issues: write + pull-requests: write on: issue_comment: types: [created] + pull_request_review_comment: + types: [created] jobs: - run-check: - if: ${{ !github.event.issue.pull_request }} # don't execute for PR comments + issue_commented: + if: github.event.issue && !github.event.issue.pull_request && github.event.comment.user.login == github.event.issue.user.login && contains(github.event.issue.labels.*.name, 'wait for update') && !contains(github.event.issue.labels.*.name, 'user responded') runs-on: ubuntu-latest steps: - name: update labels when user responds uses: actions/github-script@v6 - if: ${{ github.event.comment.user.login == github.event.issue.user.login && contains(github.event.issue.labels.*.name, 'wait for update') && !contains(github.event.issue.labels.*.name, 'user responded') }} with: script: | github.rest.issues.addLabels({ @@ -28,3 +30,33 @@ jobs: repo: context.repo.repo, name: "wait for update" }) + + pr_commented: + if: github.event.issue && github.event.issue.pull_request && github.event.comment.user.login == github.event.issue.user.login && github.event.issue.labels && !contains(github.event.issue.labels.*.name, 'user responded') + runs-on: ubuntu-latest + steps: + - name: update label when user responds + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["user responded"] + }) + + pr_review_commented: + if: github.event.pull_request && github.event.comment.user.login == github.event.pull_request.user.login && github.event.pull_request.labels && !contains(github.event.pull_request.labels.*.name, 'user responded') + runs-on: ubuntu-latest + steps: + - name: update label when user responds + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["user responded"] + })