Skip to content

Commit 4327dee

Browse files
committed
Add a GitHub Actions workflow to build and update website
1 parent 13d1930 commit 4327dee

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

.github/workflows/website.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Update website
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- 'docs/**'
8+
concurrency: website
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
website:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
- name: Setup Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
cache: pipenv
25+
- name: Install pipenv
26+
run: pip install pipenv
27+
- name: Install dependencies
28+
run: pipenv sync
29+
working-directory: docs
30+
- name: Update website
31+
run: scripts/update-website
32+
- name: Commit changes
33+
run: |
34+
if git diff --quiet; then
35+
git add --all
36+
git config user.name 'github-actions[bot]'
37+
git config user.email 'github-actions[bot]@users.noreply.github.com'
38+
git commit -m 'Update website'
39+
git push origin gh-pages
40+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jq.1
1919
# Generated source
2020
src/builtin.inc
2121
*.pc
22+
docs/output
2223

2324
# Autotools junk
2425
.libs

docs/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/update-website

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# This script builds the website from the docs directory of
44
# the current branch and copies it over to the gh-pages
55
# branch.
66

7-
set -eu
7+
set -eux
88
set -o xtrace
9+
shopt -s dotglob
910

1011
# build website
11-
scriptdir=`dirname "$0"`
12+
scriptdir=$(dirname "$0")
1213
cd "$scriptdir"/../docs
1314
rm -rf output
15+
mkdir output
1416
pipenv run python3 build_website.py
1517
cd ..
1618

@@ -20,7 +22,7 @@ cp -r docs/output/* "$tmpdir"
2022
cp .gitignore "$tmpdir"
2123

2224
# copy to gh-pages
23-
git checkout gh-pages
25+
git switch gh-pages
2426
cp -r "$tmpdir"/* .
2527
cp "$tmpdir"/.gitignore .
2628

0 commit comments

Comments
 (0)