name: Build and deploy concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write on: # Run when the main branch is pushed or a pull request is made push: branches: - main pull_request: branches: - main schedule: - cron: "*/15 * * * *" workflow_dispatch: # Run when webmentions are fetched workflow_run: workflows: - Fetch webmentions branches: - main types: - completed # Jobs jobs: build: name: Install dependencies runs-on: ubuntu-latest env: HUGO_VERSION: 0.158.0 steps: - 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: Checkout uses: actions/checkout@v6.0.2 with: submodules: recursive - name: Cache node modules uses: actions/cache@v5.0.4 env: cache-name: cache-node-modules-v1 with: path: | ~/.npm node_modules key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- - name: Setup GitHub Pages id: pages uses: actions/configure-pages@v4.0.0 - name: Set up Node.js uses: actions/setup-node@v6.3.0 with: node-version: 16 - name: Install Node.js dependencies run: npm install - name: Configure timezone as Europe/Rome uses: szenius/set-timezone@v2.0 with: timezoneLinux: Europe/Rome timezoneMacos: Europe/Rome - name: Cache built website uses: actions/cache@v5.0.4 env: cache-name: cache-website-v1 with: path: | .publish resources/_gen key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('config', 'content', 'data', 'themes') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }} - name: Build with Hugo env: # For maximum backward compatibility with Hugo modules HUGO_ENVIRONMENT: production HUGO_ENV: production run: make deploy_prod - name: Upload artifact uses: actions/upload-pages-artifact@v4.0.0 with: path: ./public deploy: name: Deploy Hugo into GitHub Pages if: github.ref == 'refs/heads/main' 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.0.5