-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (97 loc) · 3.35 KB
/
docs-quartodoc.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# adapted from https://github.com/rstudio/vetiver-python/blob/main/.github/workflows/docs.yml
name: "docs"
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
release:
types: [published]
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION_SHORT }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ccbr_actions@git+https://github.com/CCBR/actions
- name: set major & minor version
id: version
shell: python {0}
run: |
from ccbr_actions.versions import get_major_minor_version
from ccbr_actions.actions import set_output
if '${{ github.ref_type }}' == 'tag' and '${{ github.ref }}'.startswith('refs/tags/v'):
version = get_major_minor_version("${{ github.ref_name }}".lstrip("v"))
else:
version = 'dev'
set_output('VERSION_SHORT', version)
docs:
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[docs]
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: git config
shell: bash
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "41898282+github-actions[bot]"
- name: build docs
working-directory: docs
run: |
python -m quartodoc build --verbose
python -m quartodoc interlinks
quarto render
- name: save docs
uses: actions/upload-artifact@v3
with:
name: docs-html
path: docs/_site
- name: Configure pull release name
if: ${{github.event_name == 'pull_request'}}
run: |
echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV
env:
PR_NUMBER: ${{ github.event.number }}
- name: Configure branch release name
if: ${{github.event_name != 'pull_request'}}
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV
- name: publish docs
if: github.event_name != 'pull_request'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_site
publish_branch: gh-pages
destination_dir: ${{ needs.version.outputs.version }}
- name: create symlink stable to new version
if: github.ref_type == 'tag' && startswith(github.ref, 'refs/tags/v')
run: |
rm -if latest
ln -s ${{ needs.version.outputs.version }} latest
ls -la
git add latest
git commit -m 'chore: link latest docs from ${{ needs.version.outputs.version }} (tag ${{ github.ref_name }})' && git push || echo 'no changes to commit'