Reviewer Comment Dispatcher #19844
This file contains hidden or 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: Reviewer Comment Dispatcher | |
| on: | |
| workflow_run: | |
| workflows: [Reviewer Comment Router] | |
| types: [completed] | |
| permissions: | |
| actions: write | |
| contents: read | |
| issues: read | |
| pull-requests: read | |
| jobs: | |
| dispatch: | |
| name: Dispatch reviewer comment | |
| if: github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Checkout workflow scripts | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: main | |
| persist-credentials: false | |
| - name: Find reviewer comment | |
| id: find-comment | |
| uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9 | |
| with: | |
| script: | | |
| const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.payload.workflow_run.id, | |
| per_page: 100, | |
| }); | |
| const found = artifacts.some((artifact) => artifact.name === 'reviewer-comment' && !artifact.expired); | |
| core.setOutput('found', `${found}`); | |
| - name: Download reviewer comment | |
| id: download-comment | |
| if: steps.find-comment.outputs.found == 'true' | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: reviewer-comment | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ github.token }} | |
| path: reviewer-comment | |
| - name: Dispatch selected reviewer | |
| if: steps.find-comment.outputs.found == 'true' | |
| uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9 | |
| with: | |
| script: | | |
| const { dispatchReviewerComment } = require('./.github/scripts/reviewer_comment'); | |
| await dispatchReviewerComment({ github, context, core }); |