Skip to content

Commit

Permalink
ci: fix cache, improve feedback and build times
Browse files Browse the repository at this point in the history
Fix hugo_cache not being where we expect it to be by setting the
HUGO_CACHEDIR env variable to something predetermined.

Improve the feedback on PRs by now also running on pull requests, but
then only build the website to catch some errors; do not set up GH Pages
nor upload any pages artifact.
Future work may entail adding some linters and grammar checkers.

Signed-off-by: Luca Zeuch <[email protected]>
  • Loading branch information
l-zeuch committed Dec 22, 2023
1 parent 0e89e88 commit b5f0481
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ name: Deploy Hugo site to GH Pages
on:
# Only deploy when it is accepted for production
push:
branches:
- master
pull_request:
workflow_dispatch:

permissions:
Expand All @@ -17,6 +16,9 @@ concurrency:
group: "pages"
cancel-in-progress: false

env:
HUGO_CACHEDIR: /tmp/hugo_cache/

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -35,7 +37,7 @@ jobs:
- name: Cache Hugo modules
uses: actions/cache@v3
with:
path: /home/runner/.cache/hugo_cache
path: ${{ env.HUGO_CACHEDIR }}
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
Expand All @@ -46,15 +48,19 @@ jobs:
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
Expand Down

0 comments on commit b5f0481

Please sign in to comment.