Build and deploy to GitHub Pages #598
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 and deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| # repository_dispatch: | |
| # types: [trigger-deploy] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read hugo version from file | |
| id: hugo-version | |
| run: echo "HUGO_VERSION=$(cat HUGO_VERSION)" >> $GITHUB_OUTPUT | |
| - name: Add hugo nodejs dependencies | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: 'npm' | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| # sync versions with docker-compose .env ala | |
| # https://github.com/marketplace/actions/hugo-setup#%EF%B8%8F-read-hugo-version-from-file | |
| hugo-version: "${{ steps.hugo-version.outputs.HUGO_VERSION }}" | |
| extended: true | |
| - name: Build Hugo site | |
| env: | |
| HUGO_ENV: "production" | |
| run: | | |
| npm install | |
| hugo mod tidy | |
| hugo --minify | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| env: | |
| HUGO_ENV: "production" | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./public | |
| publish_branch: gh-pages |