mirror of
https://github.com/uutils/tar.git
synced 2026-06-10 16:14:35 -07:00
67 lines
2.2 KiB
YAML
67 lines
2.2 KiB
YAML
name: GnuComment
|
|
|
|
# spell-checker:ignore zizmor backquote
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["GnuTests"]
|
|
types:
|
|
- completed
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
post-comment:
|
|
permissions:
|
|
actions: read # to list workflow runs artifacts
|
|
pull-requests: write # to comment on pr
|
|
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
github.event.workflow_run.event == 'pull_request'
|
|
steps:
|
|
- name: 'Download artifact'
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: ${{ github.event.workflow_run.id }},
|
|
});
|
|
const matchArtifact = artifacts.data.artifacts.find(a => a.name === "comment");
|
|
if (!matchArtifact) {
|
|
return core.info("No 'comment' artifact found");
|
|
}
|
|
const download = await github.rest.actions.downloadArtifact({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
artifact_id: matchArtifact.id,
|
|
archive_format: 'zip',
|
|
});
|
|
const fs = require('fs');
|
|
fs.writeFileSync('${{ github.workspace }}/comment.zip', Buffer.from(download.data));
|
|
|
|
- name: 'Unzip artifact'
|
|
run: unzip comment.zip
|
|
|
|
- name: 'Comment on PR'
|
|
uses: actions/github-script@v9
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const fs = require('fs');
|
|
if (!fs.existsSync('./NR') || !fs.existsSync('./result.txt')) {
|
|
return core.info("No NR or result.txt found, skipping comment");
|
|
}
|
|
const issue_number = Number(fs.readFileSync('./NR', 'utf8').trim());
|
|
const content = fs.readFileSync('./result.txt', 'utf8').trim();
|
|
if (content.length > 0) {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue_number,
|
|
body: `### GNU Testsuite Comparison\n\n\`\`\`\n${content}\n\`\`\``
|
|
});
|
|
}
|