Add workflow to add artifact links to PR descriptions (#1961)

This commit is contained in:
Garrett Cox 2022-11-14 08:50:26 -06:00 committed by GitHub
parent 15a9975200
commit 336d129114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

37
.github/workflows/pr-artifacts.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: pr-artifacts
on:
workflow_run:
workflows: [generate-builds]
types:
- completed
jobs:
pr-artifacts:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.event == 'pull_request' }}
steps:
- id: 'get-info'
uses: actions/github-script@v6
with:
result-encoding: string
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
return allArtifacts.data.artifacts.reduce((acc, item) => {
if (item.name === "assets") return acc;
acc += `
- [${item.name}](${context.payload.repository.html_url}/suites/${context.payload.workflow_run.check_suite_id}/artifacts/${item.id})`;
return acc;
}, '### Build Artifacts');
- id: 'add-to-pr'
uses: garrettjoecox/pr-section@3.1.0
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
section-name: 'artifacts'
section-value: '${{ steps.get-info.outputs.result }}'