-
Notifications
You must be signed in to change notification settings - Fork 88
84 lines (83 loc) · 3.21 KB
/
pages.yml
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
# see https://github.com/actions/starter-workflows/blob/main/pages/jekyll.yml
name: site
on:
push: {branches: [main], tags-ignore: ['**']}
pull_request:
schedule: [{cron: '0 10 * * 6'}] # M H d m w (Sat 10:00)
permissions:
# allow GITHUB_TOKEN to deploy to GitHub Pages
contents: read
pages: write
id-token: write
concurrency: {group: "${{ github.ref }}-pages", cancel-in-progress: true}
env:
SITE_PREFIX: state-of-open-source-ai
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/setup-python@v4
with: {python-version: '3.11'}
- run: pip install -r requirements.txt pyyaml
- name: check CITATION.cff & .zenodo.json
run: |
python <<EOF
import json, yaml
cff = yaml.safe_load(open("CITATION.cff"))
zen = json.load(open(".zenodo.json"))
assert cff['title'] == zen['title'] + " Book"
assert len(cff['authors']) - 1 == len(zen['creators'])
for cauth, zauth in zip(cff['authors'][:-1], zen['creators']):
assert zauth['name'] == f"{cauth['family-names']}, {cauth['given-names']}"
assert zauth.get('affiliation', "") == cauth.get('affiliation', "")
assert zauth.get('orcid', "") == cauth.get('orcid', "").rsplit("/", 1)[-1]
assert [{'name': cff['authors'][-1]['name'], 'type': "Other"}] == zen['contributors']
assert cff['abstract'] == zen['description']
assert cff['url'] == zen['related_identifiers'][0]['identifier']
assert cff['keywords'] == zen['keywords']
EOF
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/setup-python@v4
with: {python-version: '3.11'}
- id: pages
uses: actions/configure-pages@v3
- run: pip install -r requirements.txt
- name: jupyter-book build
run: |
sudo apt update -qq
sudo apt install -qq ghostscript fonts-freefont-otf # https://stackoverflow.com/a/69012150
sed -ri 's#^(\s*baseurl:).*#\1 ${{ steps.pages.outputs.base_url }}/'$SITE_PREFIX'#g' _config.yml
jupyter-book build --builder dirhtml --warningiserror --nitpick --keep-going .
# fix https://github.com/executablebooks/jupyter-book/issues/2066
sed -ri 's#(.*link rel="canonical" href=".*)\.html(".*)#\1/\2#' _build/dirhtml/*/index.html
- uses: xu-cheng/latex-action@v3
with:
working_directory: _build/latex
root_file: book.tex
args: -pdf -dvi- -ps- -file-line-error -f -interaction=nonstopmode
latexmk_use_xelatex: true
env:
XINDYOPTS: -L english -C utf8 -M sphinx.xdy
continue-on-error: true
- name: prepare _site pages
run: |
mkdir _site
mv _build/dirhtml _site/$SITE_PREFIX
sed "s#DESTINATION#${{ steps.pages.outputs.base_url }}/$SITE_PREFIX#g" .redirect-template.html > _site/index.html
- uses: actions/upload-pages-artifact@v2
deploy:
if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [check, build]
steps:
- id: deployment
uses: actions/deploy-pages@v2