Debian Codegraph @

.github/workflows/site.yml

raw
1 name: Site
2
3 on:
4 push:
5 branches: [main]
6 pull_request:
7 branches: [main]
8 workflow_dispatch:
9
10 concurrency:
11 group: site
12 cancel-in-progress: true
13
14 permissions:
15 contents: write
16
17 jobs:
18 deploy:
19 runs-on: ubuntu-latest
20 steps:
21 - uses: actions/checkout@v5
22 with:
23 fetch-depth: 0
24
25 - uses: actions/setup-go@v6
26 with:
27 go-version-file: go.mod
28
29 - name: Install Hugo
30 run: go install github.com/gohugoio/[email protected]
31
32 - name: Install pandoc
33 run: sudo apt-get update && sudo apt-get install -y pandoc
34
35 - name: Build site
36 run: make docs
37
38 - name: Publish to gh-pages
39 run: |
40 set -euo pipefail
41
42 git config user.name "github-actions[bot]"
43 git config user.email "github-actions[bot]@users.noreply.github.com"
44
45 publish_dir="$(mktemp -d)"
46
47 if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then
48 git fetch origin gh-pages
49 git worktree add "$publish_dir" origin/gh-pages
50 else
51 git worktree add --detach "$publish_dir"
52 (
53 cd "$publish_dir"
54 git checkout --orphan gh-pages
55 )
56 fi
57
58 find "$publish_dir" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
59 cp -a site/public/. "$publish_dir"/
60
61 (
62 cd "$publish_dir"
63 touch .nojekyll
64 git add -A
65 if git diff --cached --quiet; then
66 echo "No site changes to publish"
67 exit 0
68 fi
69 git commit -m "Deploy site from ${GITHUB_SHA}"
70 git push --force origin HEAD:gh-pages
71 )