@@ -284,6 +284,9 @@ jobs:
284284 env :
285285 HANGAR_API_TOKEN : ${{ secrets.HANGAR_API_TOKEN }}
286286 RELEASE_TAG : ${{ steps.release-tag.outputs.tag }}
287+ # The checkout may be an old release tag that predates the Hangar
288+ # page source. Read it from the exact commit supplying this workflow.
289+ WORKFLOW_SHA : ${{ github.workflow_sha }}
287290 run : |
288291 set -euo pipefail
289292
@@ -296,6 +299,10 @@ jobs:
296299 echo "::error::Release tag is empty; cannot publish a Hangar version."
297300 exit 1
298301 fi
302+ if [ -z "${WORKFLOW_SHA:-}" ]; then
303+ echo "::error::Workflow commit is empty; cannot load the authoritative Hangar page."
304+ exit 1
305+ fi
299306
300307 API="https://hangar.papermc.io/api/v1"
301308 PROJECT="Connect"
@@ -333,7 +340,16 @@ jobs:
333340
334341 # Sync the public resource page before creating an immutable version.
335342 # If the token lacks edit_page, fail before partially publishing.
336- jq -n --rawfile content .github/hangar-description.md \
343+ # Backfills check out the release tag, which may predate this file,
344+ # so fetch it from the immutable commit that supplied the workflow.
345+ curl -sS --fail -A "$UA" \
346+ "https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$WORKFLOW_SHA/.github/hangar-description.md" \
347+ -o "$TMP/hangar-description.md"
348+ if [ ! -s "$TMP/hangar-description.md" ]; then
349+ echo "::error::The authoritative Hangar resource page is empty."
350+ exit 1
351+ fi
352+ jq -n --rawfile content "$TMP/hangar-description.md" \
337353 '{path: "", content: $content}' > "$TMP/page.json"
338354 PAGE_CODE="$(api "$TMP/page-response.json" \
339355 -X PATCH "$API/pages/edit/$PROJECT" \
0 commit comments