Skip to content

ci: fix cache, improve feedback and build times #17

ci: fix cache, improve feedback and build times

ci: fix cache, improve feedback and build times #17

Workflow file for this run

---
name: Deploy Hugo site to GH Pages
on:
# Only deploy when it is accepted for production
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
env:
HUGO_CACHEDIR: /tmp/hugo_cache/
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: latest
# We use the extended version just to be on the safe side.
# It is recommended anyway.
extended: true
- name: Cache Hugo modules
uses: actions/cache@v3
with:
path: ${{ env.HUGO_CACHEDIR }}
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Build website
# See https://discourse.gohugo.io/t/solved-what-should-be-used-for-the-value-of-site-baseurl/5896
# for why we set baseURL here and not in hugo.toml.
run: hugo --noChmod --minify --baseURL="https://botlabs-gg.github.io/yagpdb-docs-v2"
- name: Setup Pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: pages
uses: actions/configure-pages@v4
- name: Upload artifact
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: actions/upload-pages-artifact@v2
with:
path: ./public
deploy:
# Only deploy if it's actually on main branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3