diff --git a/.github/workflows/ghpages.yml b/.github/workflows/ghpages.yml index d7ce7700..3d9fd0cf 100644 --- a/.github/workflows/ghpages.yml +++ b/.github/workflows/ghpages.yml @@ -4,32 +4,71 @@ on: push: branches: - main # Set a branch to deploy + ## Receives events from remote repos + repository_dispatch: + types: [documentation] jobs: - deploy: - runs-on: ubuntu-20.04 + build: + runs-on: ubuntu-latest + env: + HUGO_VERSION: 0.123.8 steps: - - uses: actions/checkout@v2 + - name: Install Hugo CLI + run: | + wget -O "${{ runner.temp }}/hugo.deb" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" \ + && sudo dpkg -i "${{ runner.temp }}/hugo.deb" + - name: Install Dart Sass + run: sudo snap install dart-sass + - name: Checkout + uses: actions/checkout@v4 with: - submodules: true # Fetch Hugo themes (true OR recursive) + submodules: recursive fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod - - name: Setup Hugo - uses: peaceiris/actions-hugo@v2 - with: - hugo-version: 'latest' - extended: true - # extended: true + - name: Setup Pages + id: pages + uses: actions/configure-pages@v4 - - name: Build - run: npm install + - name: Install Node.js dependencies + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm install || true" + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: v1.20.x + cache: true - - name: Build - run: hugo --minify + - name: Update directives with upstream changes + if: ${{ github.event.client_payload.sha }} + env: + CORAZA_REF: ${{ github.event.client_payload.sha }} + run: | + go get -u "github.com/corazawaf/coraza/v3@${CORAZA_REF}" + go mod tidy + go run mage.go generate - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/main' + - name: Build with Hugo + env: + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo --gc --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public + path: ./public + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4