fix: add pnpm installation step to workflow #1
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: Reusable Hugo Deployment Workflow | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| hugo_version: | ||
| type: string | ||
| default: '0.143.0' | ||
| required: false | ||
| base_url: | ||
| type: string | ||
| default: 'https://d-oit.github.io' | ||
| required: false | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| HUGO_VERSION: ${{ inputs.hugo_version }} | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| fetch-depth: 0 | ||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: latest | ||
| - name: Set up Node.js | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: lts/* | ||
| cache: 'pnpm' | ||
| cache-dependency-path: 'pnpm-lock.yaml' | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
| - name: Lint the source files | ||
| run: pnpm run lint | ||
| - 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: Install Node.js dependencies | ||
| run: "[[ -f pnpm-lock.yaml ]] && pnpm install --frozen-lockfile || true" | ||
| - name: Build with Hugo | ||
| env: | ||
| HUGO_ENVIRONMENT: production | ||
| HUGO_ENV: production | ||
| TZ: America/Los_Angeles | ||
| run: | | ||
| hugo --gc --minify --baseURL "${{ inputs.base_url }}" && cd public/en && cp 404.html ../404.html | ||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: ./public | ||
| 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 | ||
| lighthouse: | ||
| runs-on: ubuntu-latest | ||
| needs: deploy | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Audit URLs using Lighthouse | ||
| uses: treosh/lighthouse-ci-action@v12 | ||
| with: | ||
| urls: | | ||
| ${{ inputs.base_url }}/en/ | ||
| ${{ inputs.base_url }}/en/blog/ | ||
| ${{ inputs.base_url }}/de/ | ||
| ${{ inputs.base_url }}/de/blog/ | ||
| ${{ inputs.base_url }}/en/projects/ | ||
| uploadArtifacts: true | ||
| temporaryPublicStorage: true | ||