forked from emuflight/EmuFlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ed71fb
commit fa8eec5
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Pin artifacts | ||
on: | ||
workflow_run: | ||
workflows: ["Build EmuFlight"] | ||
types: ["completed"] | ||
|
||
jobs: | ||
# Make artifacts links more visible for the upstream project | ||
pin-artifacts: | ||
permissions: | ||
statuses: write | ||
name: Add artifacts links to commit statuses | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add artifacts links to commit status | ||
run: | | ||
set -x | ||
workflow_id=${{ github.event.workflow_run.workflow_id }} | ||
run_id=${{ github.event.workflow_run.id }} # instead of ${{ github.run_id }} | ||
run_number=${{ github.event.workflow_run.run_number }} | ||
head_branch=${{ github.event.workflow_run.head_branch }} | ||
head_sha=${{ github.event.workflow_run.head_sha }} # instead of ${{ github.event.pull_request.head.sha }} (or ${{ github.sha }}) | ||
check_suite_id=${{ github.event.workflow_run.check_suite_id }} | ||
set +x | ||
curl \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${run_id}/artifacts" \ | ||
| jq '[.artifacts | .[] | {"id": .id, "name": .name, "created_at": .created_at, "expires_at": .expires_at, "archive_download_url": .archive_download_url}] | sort_by(.name)' \ | ||
> artifacts.json | ||
cat artifacts.json | ||
< artifacts.json jq -r ".[] | \ | ||
.name + \"§\" + \ | ||
( .id | tostring | \"https://github.com/${{ github.repository }}/suites/${check_suite_id}/artifacts/\" + . ) + \"§\" + \ | ||
( \"Link to \" + .name + \".zip [\" + ( .created_at | sub(\"T.*\"; \"→\") ) + ( .expires_at | sub(\"T.*\"; \"] (you must be logged)\" ) ) )" \ | ||
| while IFS="§" read name url descr; do | ||
curl \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ github.token }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/statuses/${head_sha}" \ | ||
-d "$( printf '{"state":"%s","target_url":"%s","description":"%s","context":"%s"}' "${{ github.event.workflow_run.conclusion }}" "$url" "$descr" "$name (artifact)" )" | ||
done |