-
-
Notifications
You must be signed in to change notification settings - Fork 696
65 lines (58 loc) · 2.3 KB
/
attach_build_products.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Attach Build Products
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
on:
workflow_run:
workflows: ["Build and Upload Provenance"]
types:
- completed
jobs:
artifacts-url-comments:
name: add artifact links to pull request and related issues job
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download workflow artifact data
uses: actions/github-script@v6
id: artifacts
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
return artifacts.data;
- name: add artifact links to pull request and related issues step
uses: tonyhallett/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prefix: Builds for this Pull Request are available at
suffix: Have a nice day.
format: name
addTo: pull
- name: Notify Discord with Download Links
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
ARTIFACTS_JSON='${{ steps.artifacts.outputs.result }}'
# Create download links list
DOWNLOAD_LINKS=""
while IFS= read -r artifact; do
name=$(echo $artifact | jq -r '.name')
url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/${{ github.event.workflow_run.id }}/artifacts/$(echo $artifact | jq -r '.id')"
DOWNLOAD_LINKS+="• [${name}](${url})\n"
done < <(echo "$ARTIFACTS_JSON" | jq -c '.artifacts[]')
curl -H "Content-Type: application/json" -X POST $DISCORD_WEBHOOK \
-d '{
"embeds": [{
"title": "🎮 New Provenance Builds Available",
"description": "New builds are ready for download:\n'"${DOWNLOAD_LINKS}"'",
"color": 5814783,
"footer": {
"text": "Pull Request #${{ github.event.workflow_run.pull_requests[0].number }}"
}
}]
}'