Accessibility edits #1828
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy PR branches | |
| on: | |
| pull_request: | |
| branches-ignore: "assets-update" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TARGET_REPO: "mkdocs-demo-deploy" | |
| TARGET_OWNER: "CallumWalley" | |
| WORKFLOW_ID: "deploy.yml" | |
| DEPLOY_URL: "https://callumwalley.github.io/mkdocs-demo-deploy" | |
| HEAD: ${{ github.event.pull_request.head.ref }} | |
| GH_REPO: ${{ github.repository }} | |
| permissions: write-all | |
| jobs: | |
| demo-deploy: | |
| name: Trigger test deployments | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Trigger Workflow in Another Repository | |
| run: | | |
| set -x | |
| 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}/dispatches \ | |
| -d "{\"event_type\":\"deploy\",\"client_payload\":{\"targets\":\"${GITHUB_REPOSITORY}:${HEAD}\", \"use-cache\":\"true\"}}" | |
| - name: Post initial loading comment | |
| id: comment | |
| run: | | |
| msg="Deployment in progress...<br><br>\ | |
| <img src='https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif' width=20% \ | |
| alt='a cool spinny thing'><br><br>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: | | |
| set -x | |
| echo $0 | |
| conclusion="${{ steps.wait.outputs.conclusion }}" | |
| finished="${{ steps.wait.outputs.completed_at }}" | |
| if [ "$conclusion" = "success" ]; then | |
| msg="<strong>Test deployment successful!!</strong> (${finished})<br>Preview available at \ | |
| <a href=\"${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}\">${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}</a>" | |
| # 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}<br><br>Seems the following pages differ;<br><ul>" | |
| for f in ${changed_pages};do | |
| g=${f#*/}; h=${g%.*} | |
| msg="${msg}<li><a href=\"${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}/${h}\" target=_blank>${h##*/}</a></li>" | |
| done | |
| msg="${msg}</ul>" | |
| echo "::info title=Deploy Succeeded::${DEPLOY_URL}/${GITHUB_REPOSITORY}/${HEAD}" | |
| fi | |
| msg="${msg}<br><br><em><a href="${DEPLOY_URL}">See all deployed demo sites</a></em>" | |
| else | |
| msg="Deployment failed (${conclusion})" | |
| echo "::error title=Deploy failed::${conclusion}" | |
| fi | |
| # Update message in pull request. | |
| gh pr comment "${HEAD}" --edit-last --create-if-none --body "${msg}" |