-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (89 loc) · 3.91 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: Compile documentation
on:
push:
branches:
- main
repository_dispatch:
types: [compile-docs]
permissions:
contents: write
jobs:
deploy:
env:
RELEASE_TAG: ${{ github.event.client_payload.tag }}
runs-on: ubuntu-latest
# One job at a time, cancel any pending jobs (but not those in progress).
concurrency:
group: compile-docs-${{ github.ref }}
steps:
- uses: actions/checkout@v4
with:
ref: main
path: main
- name: "Checkout the repository (stable)"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: actions/checkout@v4
with:
ref: stable
path: stable
- name: "Copy stable datasets, categories, tasks, profiles, main page, schemas"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
run: |
# Preserve the manually edited files from the main branch
cp main/docs/schema/index.md stable/docs/schema/index.md
cp main/docs/datasets/index.md stable/docs/datasets/index.md
cp main/docs/categories/index.md stable/docs/categories/index.md
# Remove the auto-generated dev content
rm -r main/docs/datasets/* main/docs/categories/* main/docs/tasks/* \
main/docs/profiles/* main/docs/schema/* main/docs/index.md || true
# Copy the stable content
cp -r stable/docs/datasets stable/docs/categories stable/docs/tasks \
stable/docs/profiles stable/docs/schema stable/docs/index.md \
main/docs || true
cp stable/docs/datasets/table.md main/docs/datasets/table.md || true
cp stable/docs/results/table.md main/docs/results/table.md || true
# *** the part about adding redirects ***
- name: "Checkout the repository (gh-pages)"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: "Add PURL redirects to the new stable release"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: docker://ghcr.io/riverbench/ci-worker:main
with:
args: bash -c "for SCHEMA in $(ls -1 main/docs/schema/*.md | grep -v index.md | grep -Po '[^/]*$') ; do ci-worker generate-redirect ./gh-pages schema \"${SCHEMA%.md}\" \"${RELEASE_TAG#v}\" ; done ; for DATASET in $(ls -1 main/docs/datasets | grep -v '[.]' | grep -Po '[^/]*$') ; do ci-worker generate-redirect ./gh-pages datasets \"${DATASET}\" \"${RELEASE_TAG#v}\" ; done"
- name: Commit changes to the gh-pages branch
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: EndBug/add-and-commit@v9
with:
cwd: ./gh-pages
message: ${{ format('Update redirects stable release ({0})', github.event.client_payload.tag) }}
default_author: github_actions
add: '.'
pull: '--rebase --autostash'
push: true
# *** end of the part about adding redirects ***
- name: Generate nav
uses: docker://ghcr.io/riverbench/ci-worker:main
with:
args: ci-worker nav-gen ./main ./main/mkdocs_2.yml
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install dependencies
run: pip install -r main/requirements.txt
- name: Deploy site
run: |
cd main
mv mkdocs_2.yml mkdocs.yml
git fetch origin gh-pages --depth=1
git config user.name ci-bot
git config user.email ci-bot@example.com
if [[ $RELEASE_TAG == v* ]] ; then
mike deploy --push --update-aliases "${RELEASE_TAG#v}" stable
else
mike deploy --push --update-aliases dev latest
fi