From 5550b780ab164dd7860e34ba3cf7925815d7e789 Mon Sep 17 00:00:00 2001 From: SatriaBagusNurhadianto Date: Mon, 16 Nov 2026 20:34:57 +0700 Subject: [PATCH] fix(ci): rebuild GitHub Pages after a release is published --- .github/workflows/go.yml | 33 +++++++++++++++++++++++++++++++++ .github/workflows/pages.yml | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 49f9480..c3760a7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -238,6 +238,10 @@ jobs: contents: write id-token: write attestations: write + # Needed to start the GitHub Pages rebuild after the release is public + # (#370). Pages cannot be started by the release event itself, because + # GITHUB_TOKEN events do not trigger other workflows. + actions: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -307,6 +311,35 @@ jobs: shell: bash run: gh release edit "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --draft=false + # pages.yml has a `release: published` trigger, but GitHub does not start a + # workflow for an event caused by GITHUB_TOKEN, so a GoReleaser publish + # never fires it (#370). Start the rebuild directly. It checks out main and + # the header reads the latest release from the Pages metadata, so the site + # shows the tag that was just published. + - name: Rebuild GitHub Pages + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + set -euo pipefail + before=$(date -u -d '10 seconds ago' +%Y-%m-%dT%H:%M:%SZ) + gh workflow run "GitHub Pages" --repo "${GITHUB_REPOSITORY}" --ref main + run_id="" + for _ in $(seq 1 10); do + run_id=$(gh run list --repo "${GITHUB_REPOSITORY}" --workflow "GitHub Pages" \ + --event workflow_dispatch --limit 10 --json databaseId,createdAt \ + | jq -r --arg before "$before" '[.[] | select(.createdAt > $before)][0].databaseId // empty') + if [ -n "${run_id}" ]; then + break + fi + sleep 3 + done + if [ -z "${run_id}" ]; then + echo "GitHub Pages workflow run did not start" >&2 + exit 1 + fi + gh run watch "${run_id}" --repo "${GITHUB_REPOSITORY}" --exit-status + # Publishes a multi-arch image to GHCR once the release itself is public # (#40). The Dockerfile cross-compiles in a build-platform builder stage, so # arm64 needs no QEMU. `latest` only moves for non-prerelease tags. diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 8da3005..dd05436 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -2,6 +2,11 @@ name: GitHub Pages # Only site changes redeploy, so a code-only push does not publish docs for # behaviour that is not released yet (#125). +# +# The `release` trigger below only fires for a release published outside the +# release workflow. GoReleaser publishes with GITHUB_TOKEN, and GitHub does not +# start a workflow for an event caused by that token, so go.yml starts this +# workflow directly after the release is public (#370). on: push: branches: