|
18 | 18 | build_website: |
19 | 19 | name: Build website |
20 | 20 | runs-on: "ubuntu-24.04" |
| 21 | + outputs: |
| 22 | + diff_status: ${{ steps.diff-generated.outputs.diff_status }} |
| 23 | + artifact_id: ${{ steps.upload-pages-package.outputs.artifact_id }} |
| 24 | + git_tree_hash: ${{ steps.diff-generated.outputs.git_tree_hash }} |
21 | 25 | steps: |
22 | 26 | - uses: actions/checkout@v6 |
23 | 27 | - name: Setup Pages |
@@ -67,13 +71,62 @@ jobs: |
67 | 71 | cd "$WORKDIR"/work |
68 | 72 | git diff --cached --stat |
69 | 73 | git diff --cached |
| 74 | + TREE_SHA1=$(git write-tree) |
| 75 | + echo "git_tree_hash=$TREE_SHA1" >> "$GITHUB_OUTPUT" |
70 | 76 | if git diff-index --quiet HEAD; then |
71 | 77 | echo "diff_status=clean" >> "$GITHUB_OUTPUT" |
72 | 78 | else |
73 | 79 | echo "diff_status=changed" >> "$GITHUB_OUTPUT" |
74 | 80 | fi |
75 | 81 | - name: Upload Pages package |
| 82 | + id: upload-pages-package |
76 | 83 | if: ${{ steps.diff-generated.outputs.diff_status == 'changed' }} |
77 | 84 | uses: actions/upload-pages-artifact@v4 |
78 | 85 | with: |
79 | 86 | path: ${{ steps.make-output-dir.outputs.doc_output_dir }}/work/ |
| 87 | + |
| 88 | + push_pages_branch: |
| 89 | + name: Update gh-pages branch |
| 90 | + needs: build_website |
| 91 | + if: $${{ needs.build_website.outputs.diff_status == 'changed' }} |
| 92 | + permissions: |
| 93 | + contents: write |
| 94 | + environment: |
| 95 | + name: pages-via-branch-push |
| 96 | + runs-on: "ubuntu-24.04" |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v6 |
| 99 | + with: |
| 100 | + ref: gh-pages |
| 101 | + path: repo |
| 102 | + - uses: actions/download-artifact@v7 |
| 103 | + with: |
| 104 | + artifact-ids: ${{ needs.build_website.outputs.artifact_id }} |
| 105 | + path: built |
| 106 | + - name: Extract Artifact |
| 107 | + env: |
| 108 | + TREE_SHA1: ${{ needs.build_website.outputs.git_tree_hash }} |
| 109 | + run: | |
| 110 | + [[ ! -z "$TREE_SHA1" ]] || { |
| 111 | + >&2 echo "did not get valid sha1 hash for expected git tree from builder job" |
| 112 | + exit 1 |
| 113 | + } |
| 114 | + tar -tf built/artifact.tar |
| 115 | + rm --one-file-system -rv -- $(git ls-tree --name-only HEAD) |
| 116 | + ls -R |
| 117 | +
|
| 118 | + publish_pages: |
| 119 | + name: Direct publish pages |
| 120 | + needs: build_website |
| 121 | + if: $${{ false && needs.build_website.outputs.diff_status == 'changed' }} |
| 122 | + permissions: |
| 123 | + pages: write |
| 124 | + id-token: write |
| 125 | + environment: |
| 126 | + name: github-pages |
| 127 | + url: ${{ steps.deployment.outputs.page_url }} |
| 128 | + runs-on: "ubuntu-24.04" |
| 129 | + steps: |
| 130 | + - name: Deploy to GitHub Pages |
| 131 | + id: deployment |
| 132 | + uses: actions/deploy-pages@v4 |
0 commit comments