Skip to content

Commit d2eb04a

Browse files
committed
Add CI workflow to build Docker ctr img with offline copy of the docs
1 parent d3268ec commit d2eb04a

5 files changed

Lines changed: 193 additions & 2 deletions

File tree

.github/dependabot.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
# Maintain dependencies for GitHub Actions
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: "monthly"
13+
commit-message:
14+
prefix: build(ci)
15+
groups:
16+
ci:
17+
patterns:
18+
- '*'
19+
20+
# Maintain dependencies for npm
21+
- package-ecosystem: "npm"
22+
directory: "/"
23+
schedule:
24+
interval: "monthly"
25+
commit-message:
26+
prefix: build(pip)
27+
groups:
28+
pip:
29+
patterns:
30+
- '*'
31+
32+
# Maintain dependencies for docker
33+
- package-ecosystem: "docker"
34+
directory: "/"
35+
schedule:
36+
interval: "monthly"
37+
commit-message:
38+
prefix: build(docker)
39+
groups:
40+
docker:
41+
patterns:
42+
- '*'

.github/workflows/build-docker.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: build-docker
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'main'
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
merge_group:
12+
workflow_dispatch:
13+
inputs:
14+
git-ref:
15+
description: 'Git ref (optional)'
16+
required: false
17+
18+
env:
19+
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
20+
IMAGE_NAME: 'project-docs'
21+
MAIN_BRANCH: 'master' # pushing to the main branch will update the "edge" tag on the image
22+
BETA_BRANCH: 'beta' # pushing to this branch will update the "beta" tag on the image
23+
STABLE_BRANCH: 'stable' # pushing to this branch will update the "stable" tag on the image
24+
TAG_PREFIX: 'v' # pushing tags with this prefix will add a version tag to the image and update the "latest" tag on the image
25+
PUSH_IMAGE: ${{ (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) || github.event_name == 'push' || github.event_name == 'push tag' }}
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
packages: write
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
variant:
37+
- default
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
# Only fetch files we actually need:
42+
fetch-depth: 0
43+
filter: 'blob:none'
44+
45+
# Build documentation website
46+
- name: Install poetry
47+
run: pipx install poetry==2.1.3
48+
49+
- name: Set up Node
50+
uses: actions/setup-node@v2
51+
with:
52+
node-version: "19" # FIXME: this is very old and out-of-date. Bump the version!
53+
54+
- name: Install build dependencies
55+
run: |
56+
npm install
57+
58+
- name: Make documentation ${{ matrix.variant }}
59+
if: matrix.variant != 'default'
60+
working-directory: documentation
61+
run: npm run make-${{ matrix.variant }}
62+
63+
- name: Build documentation
64+
run: npm run build
65+
66+
# Work around a bug where capital letters in the GitHub username (e.g. "PlanktoScope") make it
67+
# impossible to push to GHCR. See https://github.com/macbre/push-to-ghcr/issues/12
68+
- name: Lowercase image registry and owner
69+
id: image_registry_case
70+
uses: ASzc/change-string-case-action@v6
71+
with:
72+
string: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
73+
74+
- name: Set documentation variant suffix
75+
run: |
76+
if [[ '${{ matrix.variant }}' != 'default' ]]; then
77+
echo 'VARIANT_SUFFIX=-${{ matrix.variant}}' >> $GITHUB_ENV
78+
fi
79+
80+
# Build and publish Docker container image
81+
- name: Get Docker metadata
82+
id: meta
83+
uses: docker/metadata-action@v5
84+
env:
85+
DOCKER_METADATA_PR_HEAD_SHA: true
86+
IS_MAIN_BRANCH: ${{ github.ref == format('refs/heads/{0}', env.MAIN_BRANCH) }}
87+
IS_BETA_BRANCH: ${{ github.ref == format('refs/heads/{0}', env.BETA_BRANCH) }}
88+
IS_STABLE_BRANCH: ${{ github.ref == format('refs/heads/{0}', env.STABLE_BRANCH) }}
89+
with:
90+
images: ${{ steps.image_registry_case.outputs.lowercase }}
91+
flavor: |
92+
suffix=${{ env.VARIANT_SUFFIX }}
93+
tags: |
94+
type=match,pattern=${{ env.TAG_PREFIX }}(.*),group=1 # this implicitly updates latest
95+
type=raw,value=stable,enable=${{ env.IS_STABLE_BRANCH }},priority=702
96+
type=raw,value=beta,enable=${{ env.IS_BETA_BRANCH }},priority=701
97+
type=edge,branch=${{ env.MAIN_BRANCH }}
98+
type=ref,event=pr
99+
type=sha,priority=100
100+
101+
- name: Set up QEMU
102+
uses: docker/setup-qemu-action@v3
103+
104+
- name: Set up Docker Buildx
105+
uses: docker/setup-buildx-action@v3
106+
107+
- name: Log in to GitHub Container Registry
108+
if: env.PUSH_IMAGE == 'true'
109+
uses: docker/login-action@v3
110+
with:
111+
registry: ghcr.io
112+
username: ${{ github.repository_owner }}
113+
password: ${{ secrets.GITHUB_TOKEN }}
114+
115+
- name: Build and push
116+
uses: docker/build-push-action@v6
117+
with:
118+
context: ./documentation
119+
pull: true
120+
platforms: linux/amd64,linux/arm64
121+
tags: ${{ steps.meta.outputs.tags }}
122+
labels: ${{ steps.meta.outputs.labels }}
123+
push: ${{ env.PUSH_IMAGE }}
124+
125+
# Upload documentation website as archive
126+
- name: Upload website archive
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: documentation-website${{ env.VARIANT_SUFFIX }}
130+
path: documentation/site

.github/workflows/deploydocusaurus.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ jobs:
1818
steps:
1919
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2020
- name: Check out repo
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
22+
with:
23+
# Only fetch files we actually need:
24+
fetch-depth: 0
25+
filter: 'blob:none'
26+
2227
# Node is required for npm
2328
- name: Set up Node
2429
uses: actions/setup-node@v2
2530
with:
26-
node-version: "19"
31+
node-version: "19" # FIXME: this is very old and out-of-date. Bump the version!
32+
2733
# Install and build Docusaurus website
2834
- name: Build Docusaurus website
2935
run: |
3036
npm install
3137
npm run build
38+
3239
- name: Deploy 🚀
3340
uses: JamesIves/github-pages-deploy-action@releases/v3
3441
with:

Caddyfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
auto_https off
3+
}
4+
5+
:80 {
6+
root * /srv
7+
file_server
8+
}

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM caddy:2.10.2
2+
3+
COPY Caddyfile /etc/caddy/Caddyfile
4+
COPY site /srv

0 commit comments

Comments
 (0)