|
| 1 | +name: Comment on the pull request |
| 2 | + |
| 3 | +# read-write repo token |
| 4 | +# access to secrets |
| 5 | +on: |
| 6 | + workflow_run: |
| 7 | + workflows: ["Breakage"] |
| 8 | + types: |
| 9 | + - completed |
| 10 | + |
| 11 | +jobs: |
| 12 | + upload: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: > |
| 15 | + ${{ github.event.workflow_run.event == 'pull_request' && |
| 16 | + github.event.workflow_run.conclusion == 'success' }} |
| 17 | + steps: |
| 18 | + - name: 'Download artifact' |
| 19 | + |
| 20 | + with: |
| 21 | + script: | |
| 22 | + var artifacts = await github.actions.listWorkflowRunArtifacts({ |
| 23 | + owner: context.repo.owner, |
| 24 | + repo: context.repo.repo, |
| 25 | + run_id: ${{github.event.workflow_run.id }}, |
| 26 | + }); |
| 27 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 28 | + return artifact.name == "pr" |
| 29 | + })[0]; |
| 30 | + var download = await github.actions.downloadArtifact({ |
| 31 | + owner: context.repo.owner, |
| 32 | + repo: context.repo.repo, |
| 33 | + artifact_id: matchArtifact.id, |
| 34 | + archive_format: 'zip', |
| 35 | + }); |
| 36 | + var fs = require('fs'); |
| 37 | + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); |
| 38 | + - run: unzip pr.zip |
| 39 | + |
| 40 | + - name: 'Comment on PR' |
| 41 | + uses: actions/github-script@v3 |
| 42 | + with: |
| 43 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + script: | |
| 45 | + var fs = require('fs'); |
| 46 | + var issue_number = Number(fs.readFileSync('./NR')); |
| 47 | + var msg = fs.readFileSync('./MSG', 'utf8'); |
| 48 | + await github.issues.createComment({ |
| 49 | + owner: context.repo.owner, |
| 50 | + repo: context.repo.repo, |
| 51 | + issue_number: issue_number, |
| 52 | + body: msg |
| 53 | + }); |
0 commit comments