mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-31 07:20:14 -05:00
Add workflow to add artifact links to PR descriptions (#1961)
This commit is contained in:
parent
15a9975200
commit
336d129114
37
.github/workflows/pr-artifacts.yml
vendored
Normal file
37
.github/workflows/pr-artifacts.yml
vendored
Normal 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 }}'
|
Loading…
Reference in New Issue
Block a user