Enforce rule-count sync in CI #33
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: Build & Deploy Docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "docs/**" | |
| - ".hugo/**" | |
| - "WHITEPAPER.md" | |
| - "README.md" | |
| - ".github/workflows/docs.yml" | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build-docs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Rust toolchain | |
| run: rustup toolchain install stable --profile minimal | |
| - name: Cache cargo registry and build | |
| uses: actions/cache@3edfce9056124e459a23f683a21433670d47daca # v4.2.3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-cargo- | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: "3.11" | |
| - name: Configure GitHub Pages | |
| id: pages | |
| uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 | |
| - name: Build grackle | |
| run: cargo build --release --locked | |
| - name: Generate Hugo content from rules | |
| env: | |
| GRACKLE_BIN: ${{ github.workspace }}/target/release/grackle | |
| HUGO_BASEURL: ${{ steps.pages.outputs.base_url || '/' }} | |
| run: python .hugo/scripts/build_docs.py | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@2752ce1d29631191ea3f27c23495fa06139a5b78 # v3 | |
| with: | |
| hugo-version: "0.141.0" | |
| extended: true | |
| - name: Verify Hugo theme submodule | |
| working-directory: .hugo | |
| run: | | |
| if [ ! -f "themes/hugo-theme-relearn/layouts/_default/baseof.html" ]; then | |
| echo "ERROR: Theme submodule not populated. Did checkout run with submodules: recursive?" | |
| exit 1 | |
| fi | |
| - name: Build Hugo site | |
| working-directory: .hugo | |
| env: | |
| HUGO_ENVIRONMENT: production | |
| HUGO_BASEURL: ${{ steps.pages.outputs.base_url || '/' }} | |
| run: | | |
| hugo --minify --baseURL "${HUGO_BASEURL}" | |
| if [ ! -f public/index.html ]; then | |
| echo "ERROR: Hugo build failed - no index.html generated" | |
| exit 1 | |
| fi | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 | |
| with: | |
| path: .hugo/public | |
| deploy-docs: | |
| needs: build-docs | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 |