Skip to content

Commit a4dfec5

Browse files
committed
gh-actions: publisher extract run_id from url
1 parent eb66211 commit a4dfec5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
build_run_id:
7-
description: "Workflow run id that produced build artifacts"
7+
description: "Workflow URL or Run ID that produced build artifacts"
88
required: true
99
type: string
1010
verify_attestation:
@@ -87,10 +87,24 @@ jobs:
8787
- name: 📀 Metadata
8888
id: runmeta
8989
env:
90+
RUN_ID_OG: ${{ env.RUN_ID }}
9091
RUN_ID: ${{ env.RUN_ID }}
9192
GH_TOKEN: ${{ github.token }}
9293
run: |
9394
set -euo pipefail
95+
# Allow RUN_ID to be passed as a full GitHub Actions run URL.
96+
# Example: https://github.com/celzero/firestack/actions/runs/20923345284
97+
RUN_ID="${RUN_ID%%\?*}" # strip query
98+
RUN_ID="${RUN_ID%%\#*}" # strip fragment
99+
RUN_ID="${RUN_ID%/}" # strip trailing slash
100+
case "$RUN_ID" in
101+
*github.com/*/actions/runs/*)
102+
RUN_ID="${RUN_ID##*/}"
103+
;;
104+
esac
105+
echo "::notice::Using Run ID: $RUN_ID (in: $RUN_ID_OG)"
106+
# Export normalized run id for later steps.
107+
printf 'run_id=%s\n' "$RUN_ID" >> "$GITHUB_OUTPUT"
94108
if [ -n "${VCSVER_INPUT:-}" ]; then
95109
printf 'vcsver=%s\n' "${VCSVER_INPUT}" >> "$GITHUB_OUTPUT"
96110
exit 0
@@ -111,7 +125,7 @@ jobs:
111125
uses: actions/download-artifact@v7
112126
with:
113127
pattern: ${{ env.ARTIFACT_PATTERN }}
114-
run-id: ${{ env.RUN_ID }}
128+
run-id: ${{ steps.runmeta.outputs.run_id }}
115129
github-token: ${{ github.token }}
116130
path: ${{ env.DIST_DIR }}
117131

@@ -120,7 +134,7 @@ jobs:
120134
uses: actions/download-artifact@v7
121135
with:
122136
pattern: ${{ env.SBOM_PATTERN }}
123-
run-id: ${{ env.RUN_ID }}
137+
run-id: ${{ steps.runmeta.outputs.run_id }}
124138
github-token: ${{ github.token }}
125139
path: ${{ env.DIST_DIR }}
126140

0 commit comments

Comments
 (0)