Deploy to GitHub Pages #227
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 to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'content/**' | |
| - 'translations/**' | |
| - 'templates/**' | |
| - 'site/**' | |
| - 'html-generators/generateog.java' | |
| - 'html-generators/og/**' | |
| - 'html-generators/tags.properties' | |
| - 'html-generators/categories.properties' | |
| workflow_run: | |
| workflows: ['Build Project JARs'] | |
| types: [completed] | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 2 | |
| - name: Prepare generation | |
| id: changes | |
| run: | | |
| # Generated HTML and OG images are gitignored, so every deployment | |
| # must recreate them before replacing the current Pages artifact. | |
| echo "generate=true" >> "$GITHUB_OUTPUT" | |
| echo "og=true" >> "$GITHUB_OUTPUT" | |
| - uses: actions/setup-java@v6 | |
| if: steps.changes.outputs.generate == 'true' || steps.changes.outputs.og == 'true' | |
| with: | |
| distribution: 'temurin' | |
| java-version: '25' | |
| # --- HTML generation (content/templates/translations changed) --- | |
| - name: Restore cached generate JAR and AOT | |
| id: cache-restore | |
| if: steps.changes.outputs.generate == 'true' | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: | | |
| html-generators/generate.jar | |
| html-generators/generate.aot | |
| key: generator-${{ hashFiles('html-generators/generate.java') }} | |
| - name: Generate HTML with cached JAR + AOT | |
| if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit == 'true' | |
| run: java -XX:Tier4CompileThreshold=100 -XX:AOTCache=html-generators/generate.aot -jar html-generators/generate.jar | |
| - name: Setup JBang (cache miss) | |
| if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit != 'true' | |
| uses: jbangdev/setup-jbang@main | |
| - name: Generate HTML with JBang (cache miss) | |
| if: steps.changes.outputs.generate == 'true' && steps.cache-restore.outputs.cache-hit != 'true' | |
| run: jbang html-generators/generate.java | |
| # --- OG card generation (content/templates/translations or generateog.java changed) --- | |
| - name: Restore cached generateog JAR and AOT | |
| id: cache-restore-og | |
| if: steps.changes.outputs.og == 'true' | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: | | |
| html-generators/generateog.jar | |
| html-generators/generateog.aot | |
| key: generateog-${{ hashFiles('html-generators/generateog.java') }} | |
| - name: Generate OG cards with cached JAR + AOT | |
| if: steps.changes.outputs.og == 'true' && steps.cache-restore-og.outputs.cache-hit == 'true' | |
| run: java -XX:Tier4CompileThreshold=100 -XX:AOTCache=html-generators/generateog.aot -jar html-generators/generateog.jar | |
| - name: Generate OG cards with JBang (cache miss) | |
| if: steps.changes.outputs.og == 'true' && steps.cache-restore-og.outputs.cache-hit != 'true' | |
| run: | | |
| if ! command -v jbang &> /dev/null; then | |
| echo "Installing JBang..." | |
| curl -Ls https://sh.jbang.dev | bash -s - app setup | |
| export PATH="$HOME/.jbang/bin:$PATH" | |
| fi | |
| jbang html-generators/generateog.java | |
| - name: Verify Pages artifact | |
| run: test -s site/index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v6 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v5 | |
| with: | |
| path: site | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |