[Bug Report] **Please describe the bug shortly** #1893
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Add 'replied' label | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
add-label: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- id: check-access | |
name: Check if the commenter is a collaborator | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
try{ | |
const response = await github.rest.repos.checkCollaborator({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
username: context.payload.comment.user.login, | |
}) | |
return response.status === 204 | |
} catch { | |
return false | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- id: check-issue | |
name: Check if the comment is replied in an issue | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const response = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
return response.data.pull_request === undefined | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- id: add-label | |
name: Add 'replied' label | |
if: ${{ steps.check-access.outputs.result == 'true' && steps.check-issue.outputs.result == 'true' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: process.env.labels.split(', '), | |
}) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
labels: 'replied' |