dsa-connectors/.github/workflows/comment-pr.yml

51 lines
1.7 KiB
YAML
Raw Normal View History

name: Comment on PR
on:
workflow_run:
workflows: ["PR status checks"]
types:
- completed
jobs:
comment:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
}}
steps:
- name: Download Artifact
uses: actions/github-script@v3
with:
script: |
let artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
let artifact = artifacts.data.artifacts.filter(artifact => {
return artifact.name == "pr"
})[0];
let download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data));
- run: unzip pr.zip
- name: Comment on PR
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let prNumber = Number(fs.readFileSync("./number"));
let statusCheck = fs.readFileSync("./status-check-output");
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: '```' + statusCheck + '```',
});