ci: skip page artifact upload if pages are unchanged #2
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: Rebuild Docs | ||
|
Check failure on line 1 in .github/workflows/doc_update.yml
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, ready_for_review, review_requested] | ||
| branches-ignore: | ||
| - "gh-pages" | ||
| push: | ||
| branches: | ||
| - "master" | ||
| - "doc-workflow" | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| build_website: | ||
| name: Build website | ||
| runs-on: "ubuntu-24.04" | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v5 | ||
| - name: Create Gemfile | ||
| run: | | ||
| echo $'source "https://rubygems.org"\n\ngem "jekyll"\n' > Gemfile | ||
| - name: Setup Ruby and Jekyll | ||
| uses: ruby/setup-ruby@8d27f39a5e7ad39aebbcbd1324f7af020229645c # v1.287.0 | ||
| with: | ||
| ruby-version: "4.0.1" | ||
| bundler-cache: true | ||
| - name: Cache jsonnet binary | ||
| id: cache-jsonnet-binary | ||
| uses: actions/cache@v5 | ||
| with: | ||
| key: jsonnet-bin-${{ hashFiles('include/*', 'core/*', 'cmd/*', 'cpp/*', 'third_party/**/*', 'stdlib/std.jsonnet') }} | ||
| path: ./jsonnet | ||
| - name: Build jsonnet binary | ||
| if: steps.cache-jsonnet-binary.outputs.cache-hit != 'true' | ||
| run: | | ||
| make jsonnet | ||
| - name: Set up output dir | ||
| id: make-output-dir | ||
| run: | | ||
| WORKDIR="$(mktemp -d)" | ||
| git fetch origin gh-pages | ||
| git worktree add --no-checkout --detach "$WORKDIR"/work FETCH_HEAD | ||
| echo "doc_output_dir=$WORKDIR" >> "$GITHUB_OUTPUT" | ||
| - name: Build website | ||
| env: | ||
| WORKDIR: ${{ steps.make-output-dir.outputs.doc_output_dir }} | ||
| run: | | ||
| tools/scripts/update_web_content.sh | ||
| bundler exec jekyll build -s doc -d "$WORKDIR"/work | ||
| cd "$WORKDIR"/work | ||
| # Keep existing libjsonnet.wasm. | ||
| git checkout HEAD -- js/libjsonnet.wasm | ||
| git add . | ||
| - name: Diff docs | ||
| id: diff-generated | ||
| env: | ||
| WORKDIR: ${{ steps.make-output-dir.outputs.doc_output_dir }} | ||
| run: | | ||
| cd "$WORKDIR"/work | ||
| git diff --cached --stat | ||
| git diff --cached | ||
| if git diff-index --quiet; then | ||
| echo "diff_status=changed" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "diff_status=clean" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| - name: Upload Pages package | ||
| if: steps.diff-generated.outputs.diff_status == "changed" | ||
| uses: actions/upload-pages-artifact@v4 | ||
| with: | ||
| path: ${{ steps.make-output-dir.outputs.doc_output_dir }}/work/ | ||