Skip to content

Comment on the pull request #1147

Comment on the pull request

Comment on the pull request #1147

Workflow file for this run

name: Comment on the pull request
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ["PR Maintenance"]
types:
- completed
jobs:
comment-stats:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request'
permissions:
pull-requests: write
steps:
- name: "Download artifact"
uses: actions/[email protected]
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Find PR
id: find-pr
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
return issue_number
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
continue-on-error: true
with:
issue-number: ${{ steps.find-pr.outputs.result }}
comment-author: "github-actions[bot]"
body-includes: <!-- CI Comment -->
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ steps.find-pr.outputs.result }}
body-file: comment.md
edit-mode: replace