chores: cleanup deployments #105
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: publish | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: github-pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # Run all steps inside the Hugo + Node container | |
| container: | |
| image: floryn90/hugo:ext-alpine | |
| options: --user 0 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # Computes the correct base URL | |
| - name: Configure Pages | |
| id: pages | |
| uses: actions/configure-pages@v5 | |
| # Git is needed for Hugo Modules resolution | |
| - name: Install git | |
| run: | | |
| apk add --no-cache git tar nodejs npm | |
| npm i -D postcss postcss-cli autoprefixer | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| # Cache Hugo's module/remote cache | |
| - name: Cache Hugo modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: /root/.cache/hugo | |
| key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.mod', '**/go.sum') }} | |
| restore-keys: ${{ runner.os }}-hugo- | |
| - name: Build site | |
| env: | |
| HUGO_BASEURL: ${{ steps.pages.outputs.base_url }} | |
| run: hugo --gc --minify | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./public | |
| deploy: | |
| # Deploy only for main branch pushes (skip PRs) | |
| if: github.event_name != 'pull_request' | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - id: deployment | |
| uses: actions/deploy-pages@v4 |