-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 2.41 KB
/
reusable-hugo-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Reusable Hugo Deployment Workflow
on:
workflow_call:
inputs:
hugo_version:
type: string
default: '0.140.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: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install npm
run: npm i
- name: Lint the source files
run: npm 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 package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || 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