From 826452c8e63fad6e780e942b14b955fa9254be12 Mon Sep 17 00:00:00 2001
From: Cal <35017184+CallumWalley@users.noreply.github.com>
Date: Thu, 13 Aug 2026 11:21:53 +1200
Subject: [PATCH 1/2] Enhance demo deployment workflow with comments and waits
Updated the GitHub Actions workflow to include new steps for posting comments and waiting for deployment completion.
---
.github/workflows/demo_deploy.yml | 145 +++++++++++++++++++-----------
1 file changed, 95 insertions(+), 50 deletions(-)
diff --git a/.github/workflows/demo_deploy.yml b/.github/workflows/demo_deploy.yml
index 4efb5f3..6d41107 100644
--- a/.github/workflows/demo_deploy.yml
+++ b/.github/workflows/demo_deploy.yml
@@ -1,7 +1,6 @@
name: Deploy PR branches
on:
pull_request:
- branches-ignore: "assets-update"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_REPO: "mkdocs-demo-deploy"
@@ -9,18 +8,17 @@ env:
WORKFLOW_ID: "deploy.yml"
DEPLOY_URL: "https://callumwalley.github.io/mkdocs-demo-deploy"
HEAD: ${{ github.event.pull_request.head.ref }}
+ GH_REPO: ${{ github.repository }}
+ NO_MKDOCS_2_WARNING: "1"
permissions: write-all
jobs:
demo-deploy:
- continue-on-error: true
name: Trigger test deployments
runs-on: ubuntu-24.04
steps:
- name: Trigger Workflow in Another Repository
- continue-on-error: true
run: |
set -x
- set -o xtrace
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
@@ -28,53 +26,100 @@ jobs:
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${TARGET_OWNER}/${TARGET_REPO}/dispatches \
-d "{\"event_type\":\"deploy\",\"client_payload\":{\"targets\":\"${GITHUB_REPOSITORY}:${HEAD}\", \"use-cache\":\"true\"}}"
-
- # This would be better if it worked
- # - name: Run 'deploy.yml' Workflow
- # uses: convictional/trigger-workflow-and-wait@v1.6.1
- # with:
- # owner: ${TARGET_OWNER}
- # repo: ${TARGET_REPO}
- # github_token: ${{ secrets.PAT }}
- # workflow_file_name: deploy.yml
- # client_payload: '{"targets":"${GITHUB_REPOSITORY}:${HEAD}", "use-cache":"true"}'
- # - name: Wait for Workflow Action
- # run: |
- # curl -L \
- # -X POST \
- # -H "Accept: application/vnd.github+json" \
- # -H "Authorization: Bearer ${{ secrets.PAT }}" \
- # -H "X-GitHub-Api-Version: 2022-11-28" \
- # https://api.github.com/repos/${TARGET_OWNER}/${TARGET_REPO}/actions/runs/deploy.yml
- - name: Wait for Workflow Action
+ - name: Post initial loading comment
+ id: comment
run: |
- # Just give a minute or so to deploy
- sleep 90
- - name: Checkout repository
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - name: Post messages open requests
+ msg="Deployment in progress...
\
+ 
Waiting for test environment to finish building, please be patient ☺️"
+ gh pr comment "${HEAD}" --edit-last --create-if-none --body "${msg}"
+ - name: Wait for target workflow to complete
continue-on-error: true
+ id: wait
+ run: |
+ echo "Polling for workflow completion..."
+
+ while true; do
+ run_json=$(gh api \
+ repos/${TARGET_OWNER}/${TARGET_REPO}/actions/workflows/${WORKFLOW_ID}/runs \
+ --jq '.workflow_runs[0]')
+
+ status=$(echo "$run_json" | jq -r '.status')
+ conclusion=$(echo "$run_json" | jq -r '.conclusion')
+
+ echo "Status: $status"
+
+ if [ "$status" = "completed" ]; then
+ echo "conclusion=$conclusion" >> $GITHUB_OUTPUT
+ echo "completed_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
+ break
+ fi
+
+ sleep 10
+ done
+
+ - name: Post messages open requests
run: |
- msg="Test deployment available at ${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}"
- changed_pages="$(git diff --name-only origin/main -- '*.md')"
- # Logic for truncating out long sections commented out.
- # maxlines=-5
- if [ -n "${changed_pages}" ]; then
- msg="${msg}
Seems the following pages differ;
"
- for f in ${changed_pages};do
- # maxlines=((maxlines+1))
- #if [ ${maxlines} -lt 1 ]; then
- g=${f#*/}; h=${g%.*}
- msg="${msg}- ${h##*/}
"
- #fi
- done
- # if [ ${maxlines} -gt 0 ];then
- # msg="${msg}- ... and ${maxlines} more.
"
- # fi
- msg="${msg}
"
+ set -x
+ echo $0
+ conclusion="${{ steps.wait.outputs.conclusion }}"
+ finished="${{ steps.wait.outputs.completed_at }}"
+
+ if [ "$conclusion" = "success" ]; then
+ msg="Test deployment successful!! (${finished})
Preview available at \
+ ${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}"
+ # Get diff of main branch and feature branch.
+ changed_pages=$(gh api repos/${GITHUB_REPOSITORY}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}\
+ --jq '.files[] | select(.filename | endswith(".md")) | .filename')
+ # If changes append to message.
+ if [ -n "${changed_pages}" ]; then
+ msg="${msg}
Seems the following pages differ;
"
+ for f in ${changed_pages};do
+ g=${f#*/}; h=${g%.*}
+ msg="${msg}- ${h##*/}
"
+ done
+ msg="${msg}
"
+ echo "::info title=Deploy Succeeded::${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}"
+ fi
+ msg="${msg}
See all deployed demo sites"
+ else
+ msg="Deployment failed (${conclusion})"
+ echo "::error title=Deploy failed::${conclusion}"
fi
- msg="${msg}
See all deployed demo sites"
- (gh pr comment ${HEAD} --edit-last --body "${msg}") || (gh pr comment ${HEAD} --body "${msg}")
- echo "::info title=Deploy successful::${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}"
+ # Update message in pull request.
+ gh pr comment "${HEAD}" --edit-last --create-if-none --body "${msg}"
+
+ - name: Map changed pages to preview URLs
+ if: steps.wait.outputs.conclusion == 'success'
+ id: pages
+ run: |
+ changed_pages=$(gh api repos/${GITHUB_REPOSITORY}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} \
+ --jq '.files[] | select(.filename | endswith(".md")) | .filename')
+ urls="${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}/"$'\n'
+ for f in ${changed_pages}; do
+ g=${f#*/}; h=${g%.*}
+ urls="${urls}${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}/${h}/"$'\n'
+ done
+ echo "urls<> $GITHUB_OUTPUT
+ echo "$urls" >> $GITHUB_OUTPUT
+ echo "EOF" >> $GITHUB_OUTPUT
+
+ - name: Wait for preview URLs to be live
+ if: steps.wait.outputs.conclusion == 'success'
+ run: |
+ # GitHub Pages CDN can lag behind the deploy; a URL that 404s serves
+ # GitHub's default 404 page, whose strict CSP breaks AccessLint's
+ # script injection. Poll each URL until it returns 200 first.
+ while IFS= read -r url; do
+ [ -z "$url" ] && continue
+ echo "Waiting for $url"
+ for i in $(seq 1 30); do
+ code=$(curl -s -o /dev/null -w "%{http_code}" "$url")
+ if [ "$code" = "200" ]; then
+ echo " OK ($code)"
+ break
+ fi
+ echo " Got $code, retrying (${i}/30)..."
+ sleep 5
+ done
+ done <<< "${{ steps.pages.outputs.urls }}"
From c6c13c1203c92cf887641596db8033b21ad40965 Mon Sep 17 00:00:00 2001
From: Cal <35017184+CallumWalley@users.noreply.github.com>
Date: Thu, 13 Aug 2026 15:16:55 +1200
Subject: [PATCH 2/2] stop writing my commit messages!
agggggggggghhhhhhh
---
.github/workflows/demo_deploy.yml | 67 ++++++++++++++++++++++---------
1 file changed, 48 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/demo_deploy.yml b/.github/workflows/demo_deploy.yml
index 6d41107..5b14326 100644
--- a/.github/workflows/demo_deploy.yml
+++ b/.github/workflows/demo_deploy.yml
@@ -1,5 +1,5 @@
name: Deploy PR branches
-on:
+on:
pull_request:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -10,16 +10,23 @@ env:
HEAD: ${{ github.event.pull_request.head.ref }}
GH_REPO: ${{ github.repository }}
NO_MKDOCS_2_WARNING: "1"
-permissions: write-all
+permissions:
+ contents: read
+ pull-requests: write
+concurrency:
+ group: demo-deploy-${{ github.event.pull_request.number }}
+ cancel-in-progress: true
jobs:
demo-deploy:
name: Trigger test deployments
runs-on: ubuntu-24.04
steps:
- name: Trigger Workflow in Another Repository
+ id: trigger
run: |
set -x
- curl -L \
+ echo "dispatch_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
+ curl -fsSL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
@@ -30,34 +37,53 @@ jobs:
id: comment
run: |
msg="Deployment in progress...
\
- 
Waiting for test environment to finish building, please be patient ☺️"
+ 
Waiting for test environment to finish building, please be patient ☺️"
gh pr comment "${HEAD}" --edit-last --create-if-none --body "${msg}"
- name: Wait for target workflow to complete
- continue-on-error: true
id: wait
+ env:
+ GH_TOKEN: ${{ secrets.PAT }}
+ TIMEOUT_SECONDS: 600
run: |
- echo "Polling for workflow completion..."
+ finish() {
+ echo "conclusion=$1" >> "$GITHUB_OUTPUT"
+ echo "completed_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
+ }
+
+ # Only consider runs created after we dispatched, so a stale
+ # already-completed run isn't mistaken for the one we just triggered.
+ echo "Looking for a run created after ${{ steps.trigger.outputs.dispatch_time }}..."
+ run_id=""
+ while [ -z "$run_id" ]; do
+ if [ "$SECONDS" -ge "$TIMEOUT_SECONDS" ]; then
+ echo "Timed out waiting for the run to appear."
+ finish "timed_out"
+ exit 0
+ fi
+ run_id=$(gh api -X GET "repos/${TARGET_OWNER}/${TARGET_REPO}/actions/workflows/${WORKFLOW_ID}/runs" \
+ -f "created=>${{ steps.trigger.outputs.dispatch_time }}" \
+ --jq '.workflow_runs[-1].id // empty')
+ [ -z "$run_id" ] && sleep 10
+ done
+ echo "Tracking run $run_id"
while true; do
- run_json=$(gh api \
- repos/${TARGET_OWNER}/${TARGET_REPO}/actions/workflows/${WORKFLOW_ID}/runs \
- --jq '.workflow_runs[0]')
-
+ if [ "$SECONDS" -ge "$TIMEOUT_SECONDS" ]; then
+ echo "Timed out waiting for the run to complete."
+ finish "timed_out"
+ exit 0
+ fi
+ run_json=$(gh api "repos/${TARGET_OWNER}/${TARGET_REPO}/actions/runs/${run_id}")
status=$(echo "$run_json" | jq -r '.status')
- conclusion=$(echo "$run_json" | jq -r '.conclusion')
-
echo "Status: $status"
-
if [ "$status" = "completed" ]; then
- echo "conclusion=$conclusion" >> $GITHUB_OUTPUT
- echo "completed_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
+ finish "$(echo "$run_json" | jq -r '.conclusion')"
break
fi
-
sleep 10
done
-
+
- name: Post messages open requests
run: |
set -x
@@ -81,7 +107,7 @@ jobs:
msg="${msg}"
echo "::info title=Deploy Succeeded::${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}"
fi
- msg="${msg}
See all deployed demo sites"
+ msg="${msg}
See all deployed demo sites"
else
msg="Deployment failed (${conclusion})"
echo "::error title=Deploy failed::${conclusion}"
@@ -123,3 +149,6 @@ jobs:
sleep 5
done
done <<< "${{ steps.pages.outputs.urls }}"
+ with:
+ header: a11y
+ path: ${{ steps.a11y.outputs.report-markdown-path }}