Skip to content

Comment PR changeset status #483

Comment PR changeset status

Comment PR changeset status #483

name: Comment PR changeset status
on:
workflow_run:
workflows: ['Check PR changset']
types:
- completed
jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request'
steps:
- name: Get token
id: get_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.GREEN_BOT_APP_ID }}
private-key: ${{ secrets.GREEN_BOT_PRIVATE_KEY }}
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
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: Get PR number
id: pr_number
uses: actions/github-script@v3
with:
script: |
var fs = require('fs');
return Number(fs.readFileSync('./NR'));
- name: Comment on PR
uses: mshick/add-pr-comment@v2
with:
repo-token: ${{ steps.get_token.outputs.token }}
issue: ${{ steps.pr_number.outputs.result }}
message-path: ./COMMENT
message-id: pr-changeset-status