summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2022-11-14 08:50:26 -0600
committerGitHub <noreply@github.com>2022-11-14 15:50:26 +0100
commit336d1291144c29b9d3229bf4665e17044ae2af59 (patch)
treee56d635871ddc16fa0c49b9aea04b94fd74e5afc /.github
parent15a9975200f89e221a2ba55f132e7d1f682add59 (diff)
Add workflow to add artifact links to PR descriptions (#1961)
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/pr-artifacts.yml37
1 files changed, 37 insertions, 0 deletions
diff --git a/.github/workflows/pr-artifacts.yml b/.github/workflows/pr-artifacts.yml
new file mode 100644
index 000000000..599aa1bbb
--- /dev/null
+++ b/.github/workflows/pr-artifacts.yml
@@ -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 }}'