Skip to content

Commit a89c823

Browse files
committed
Fix GitHub Pages deployment race
The automatic pages-build-deployment workflow (Jekyll) runs on every push to main and renders README.md as the site. It was finishing after our WASM deployment, overwriting it. The live site showed README content instead of the WebAssembly demo. Changes to deploy-pages job: - Wait for the automatic Jekyll build to complete before deploying, polling by commit SHA to target only the run from this push - Add .nojekyll to the deployed artifact to suppress Jekyll processing - Add actions:read permission required by gh run list
1 parent aa59c2b commit a89c823

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
continue-on-error: true
101101
- name: Upload test artifacts
102102
if: failure()
103-
uses: actions/upload-artifact@v6
103+
uses: actions/upload-artifact@v7
104104
with:
105105
name: test-screenshots
106106
path: build/*.png
@@ -171,7 +171,7 @@ jobs:
171171
- name: Prepare deployment
172172
run: .ci/build-wasm.sh deploy-prep
173173
- name: Upload WASM artifacts
174-
uses: actions/upload-artifact@v6
174+
uses: actions/upload-artifact@v7
175175
with:
176176
name: wasm-build
177177
path: deploy/
@@ -183,17 +183,49 @@ jobs:
183183
timeout-minutes: 10
184184
runs-on: ubuntu-24.04
185185
permissions:
186+
actions: read
186187
contents: read
187188
pages: write
188189
id-token: write
189190
environment:
190191
name: github-pages
191192
url: ${{ steps.deployment.outputs.page_url }}
192193
steps:
194+
- name: Wait for automatic Pages build
195+
env:
196+
GH_TOKEN: ${{ github.token }}
197+
run: |
198+
set -euo pipefail
199+
# The automatic pages-build-deployment workflow (Jekyll) runs on
200+
# every push and renders README.md. Wait for it to finish so our
201+
# WASM deployment is always the final one.
202+
#
203+
# Filter by commit SHA to wait only for the run from this push.
204+
sleep 10
205+
for i in $(seq 1 30); do
206+
RUNNING=$(gh run list -R "${{ github.repository }}" \
207+
--workflow=pages-build-deployment \
208+
--commit "${{ github.sha }}" \
209+
--json status \
210+
--jq '[.[] | select(.status != "completed")] | length' \
211+
2>/dev/null) || RUNNING="error"
212+
if [ "$RUNNING" = "error" ]; then
213+
echo "Could not query pages-build-deployment (may be disabled)"
214+
break
215+
fi
216+
if [ "$RUNNING" = "0" ]; then
217+
echo "No competing Pages deployment running for this commit"
218+
break
219+
fi
220+
echo "Waiting for automatic Pages build... (${i}/30)"
221+
sleep 5
222+
done
193223
- uses: actions/download-artifact@v6
194224
with:
195225
name: wasm-build
196226
path: deploy/
227+
- name: Disable Jekyll processing
228+
run: touch deploy/.nojekyll
197229
- uses: actions/configure-pages@v5
198230
- uses: actions/upload-pages-artifact@v3
199231
with:

0 commit comments

Comments
 (0)