Skip to content

Set up deployment

Set up deployment #384

Workflow file for this run

name: Proof Links
on: [pull_request, workflow_dispatch]
env:
HUGO_VERSION: 0.147.8
GH_USER: cloud-cannon-teamdev-integration
LYCHEE_RELEASE: "lychee-v0.15.1-x86_64-unknown-linux-gnu.tar.gz"
LYCHEE_VERSION_TAG: "v0.15.1"
jobs:
check-links:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Hugo Modules
uses: actions/cache@v4
with:
path: /tmp/hugo_cache
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Prepare environment
run: git config --global url."https://${{ env.GH_USER }}:${{ secrets.GH_PAT }}@github.com".insteadOf "https://github.com"
- name: Install Dependencies
working-directory: site
run: npm ci
- name: Build Spine
working-directory: site
run: hugo -e development
# Cache Lychee results to avoid hitting rate limits.
- name: Cache Lychee results
uses: actions/cache@v4
with:
path: .lycheecache
key: cache-lychee-results
- name: Cache Lychee executable
id: cache-lychee
uses: actions/cache@v4
with:
path: lychee
key: ${{ runner.os }}-${{ env.LYCHEE_RELEASE }}
# We use Lychee directly instead of a GitHub Action because it
# must have access the local Hugo server, which is not visible
# from the Docker-based action.
- name: Download Lychee executable
uses: robinraju/[email protected]
if: steps.cache-lychee.outputs.cache-hit != 'true'
with:
repository: "lycheeverse/lychee"
tag: ${{ env.LYCHEE_VERSION_TAG }}
fileName: ${{ env.LYCHEE_RELEASE }}
- name: Extract Lychee executable
if: steps.cache-lychee.outputs.cache-hit != 'true'
run: |
mkdir -p lychee &&
tar -xf ${{ env.LYCHEE_RELEASE }} -C lychee
# 1. In the generated HTML, some inner links will have absolute URLs and
# the link checker will attempt to fetch them. That's why we need
# a server. Sadly, link checkers have no settings to address this.
# 2. Output redirection is necessary for nohup in GitHub Actions.
# 3. Sleep makes sure the server is up before the next step.
- name: Start Hugo server
working-directory: site
run: |
nohup hugo server \
--environment development \
> nohup.out 2> nohup.err < /dev/null &
sleep 5
- name: Check if the cache file exists
run: |
if [ -f ".lycheecache" ]; then
echo "Lychee cache exists."
else
echo "No lychee cache file."
fi
- name: Check links
run: |
./lychee/lychee --config lychee.toml --timeout 60 \
--base http://localhost:1313/ \
'site/public/**/*.html'