Skip to content

Commit 51c25b5

Browse files
mmckyclaude
andcommitted
linkcheck: harden release-asset download (Copilot review)
- add contents:read so the gh api releases call works under a restrictive permissions block - set -euo pipefail; select a single .tar.gz asset and fail with a clear error when none is found - curl -fsSL so an HTTP error page fails the step instead of being piped into tar Keeps QuantEcon/action-link-checker@main (first-party org action; matches the reference in lecture-python-programming). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fdb9e16 commit 51c25b5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

.github/workflows/linkcheck.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
name: QuantEcon AI link checking
1010
runs-on: "ubuntu-latest"
1111
permissions:
12+
contents: read # read latest release assets via gh api
1213
issues: write # required for QuantEcon link-checker
1314
steps:
1415
# Download the latest release HTML archive (permanent, not subject to artifact expiry)
@@ -17,13 +18,19 @@ jobs:
1718
env:
1819
GH_TOKEN: ${{ github.token }}
1920
run: |
21+
set -euo pipefail
2022
ASSET_URL=$(gh api repos/${{ github.repository }}/releases/latest \
21-
--jq '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')
22-
echo "asset-url=$ASSET_URL" >> $GITHUB_OUTPUT
23+
--jq '[.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url] | first // ""')
24+
if [ -z "$ASSET_URL" ]; then
25+
echo "::error::No .tar.gz asset found on the latest release"
26+
exit 1
27+
fi
28+
echo "asset-url=$ASSET_URL" >> "$GITHUB_OUTPUT"
2329
- name: Download and extract release HTML
2430
run: |
31+
set -euo pipefail
2532
mkdir -p _site
26-
curl -sL "${{ steps.release.outputs.asset-url }}" | tar -xz -C _site
33+
curl -fsSL "${{ steps.release.outputs.asset-url }}" | tar -xz -C _site
2734
- name: AI-Powered Link Checker
2835
uses: QuantEcon/action-link-checker@main
2936
with:

0 commit comments

Comments
 (0)