Skip to content

Commit

Permalink
Set hugo and node versions in one place; update gh pages workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Oct 4, 2023
1 parent 8d5765a commit b7545de
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 23 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/check-i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ name: hugo i18n check
on:
pull_request:

# versions should be kept in sync with gh-pages and lighthouse-ci workflow
env:
HUGO_VERSION: 0.119.0 # if you update this, change the README badge and lighthouse-ci.yml too!
NODE_VERSION: 18 # if you update this, change the README badge and lighthouse-ci.yml too!

jobs:
build-deploy:
name: Check Hugo i18n translations
Expand All @@ -17,12 +12,18 @@ jobs:
- name: checkout repository
uses: actions/checkout@v3

- name: Get Hugo version
run: echo "HUGO_VERSION=$(cat .hugo_version)" >> $GITHUB_ENV

- name: setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: Get node version from package.json
run: echo "NODE_VERSION=$(cat package.json | jq -r '.volta.node')" >> $GITHUB_ENV

- name: setup node.js
uses: actions/setup-node@v2-beta
with:
Expand Down
62 changes: 47 additions & 15 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
name: github pages

on:
# Runs on pushes targeting the default branch
push:
branches:
- main
branches: ["main"]

# versions should be kept in sync with lighthouse-ci workflow
env:
HUGO_VERSION: 0.119.0 # if you update this, change the README badge and lighthouse-ci.yml too!
NODE_VERSION: 18 # if you update this, change the README badge and lighthouse-ci.yml too!
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

# Default to bash
defaults:
run:
shell: bash

jobs:
build-deploy:
name: build site and deploy to github pages
build:
runs-on: ubuntu-latest

steps:
- name: checkout repository
uses: actions/checkout@v3

- name: Get Hugo version
run: echo "HUGO_VERSION=$(cat .hugo_version)" >> $GITHUB_ENV

- name: setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: Get node version from package.json
run: echo "NODE_VERSION=$(cat package.json | jq -r '.volta.node')" >> $GITHUB_ENV

- name: setup node.js
uses: actions/setup-node@v3
with:
Expand All @@ -42,11 +61,24 @@ jobs:
- name: install js dependencies
run: npm ci

- name: build site
run: hugo --minify
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--minify \
--baseURL ${{ steps.pages.outputs.base_url }}
- name: deploy site to github pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./public
# Deployment job
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@v2
9 changes: 6 additions & 3 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ name: lighthouse ci

on: [push]

# versions should be kept in sync with gh-pages workflow
env:
HUGO_VERSION: 0.119.0 # if you update this, change the README badge and gh-pages.yml too!
NODE_VERSION: 18 # if you update this, change the README badge and gh-pages.yml too!
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

jobs:
Expand All @@ -17,12 +14,18 @@ jobs:
- name: checkout repository
uses: actions/checkout@v4

- name: Get Hugo version
run: echo "HUGO_VERSION=$(cat .hugo_version)" >> $GITHUB_ENV

- name: setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: Get node version from package.json
run: echo "NODE_VERSION=$(cat package.json | jq -r '.volta.node')" >> $GITHUB_ENV

- name: setup node.js
uses: actions/setup-node@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .hugo_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.119.0
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"homepage": "https://startwords.cdh.princeton.edu/",
"engines": {
"node": ">=18"
},
"volta": {
"node": "18.18.0"
}
}

0 comments on commit b7545de

Please sign in to comment.