-
Notifications
You must be signed in to change notification settings - Fork 2
150 lines (124 loc) · 4.83 KB
/
deploy-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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# This workflow will deploy a new version of the docs to the `latest` version
# of the docs in the gh-pages branch. The repository settings must set the
# gh-pages branch as the source for the GitHub Pages site, so that it automatically
# update them.
name: Deploy to latest
on:
push:
branches: [main]
tags:
- '*.*.*'
workflow_dispatch:
schedule:
# run every week
- cron: "0 0 * * 0"
# avoid jobs modifying the gh-pages branch concurrently
concurrency:
group: staging_environment
cancel-in-progress: false
jobs:
build_and_deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: ✅ Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed for git committers
- name: 💁 Git committer set-up
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: 🐍 Install Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: 📝 Set up Python environment
run: |
pip install -U pip
pip install -r requirements.txt
- name: 🔗 Check Links
run: |
npm install markdown-link-check@"<3.11.1"
npx markdown-link-check docs/**/*.md --progress -q
- name: 📁 Set up repositories
run: sh scripts/check_out_repos.sh
- name: 📓 Set up notebooks and examples
run: sh scripts/check_out_examples.sh
# store `latest` version number into a variable
- name: 🔬 Get latest version number
id: extract-version
run: |
echo "Latest version is $(mike list | grep '\"latest\"')"
echo "Extracted version number: $(mike list | grep '\"latest\"' | sed 's/.*(\([^)]*\)).*/\1/')"
version=$(mike list | grep '\"latest\"' | sed 's/.*(\([^)]*\)).*/\1/')
echo "latest_version=$version" >> "$GITHUB_ENV"
# build docs
- name: 📚 Build Docs
run: |
pip install -U pip
pip install -r requirements.txt
# deploy to `latest` using mike
- name: 🚀 Deploy with mike
run: mike deploy --push $latest_version
update_version:
name: Update Version
runs-on: ubuntu-latest
needs: build_and_deploy
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
steps:
- name: ✅ Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed for git committers
- name: 💁 Git committer set-up
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# check that tag matches `/v[0-9]+(\.[0-9]+)*/`
- name: 🏷️ Check tag
id: check-tag
run: echo "tag_version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: 🐍 Install Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: 📝 Set up Python environment
run: |
pip install -U pip
pip install -r requirements.txt
- name: 🔗 Check Links
run: |
npm install markdown-link-check@"<3.11.1"
npx markdown-link-check docs/**/*.md --progress -q
- name: 📁 Set up repositories
run: sh scripts/check_out_repos.sh
- name: 📓 Set up notebooks
run: sh scripts/check_out_notebooks.sh
# store `latest` version number into a variable
- name: 🔬 Get latest version number
id: extract-version
run: |
echo "Latest version is $(mike list | grep '\"latest\"')"
echo "Extracted version number: $(mike list | grep '\"latest\"' | sed 's/.*(\([^)]*\)).*/\1/')"
version=$(mike list | grep '\"latest\"' | sed 's/.*(\([^)]*\)).*/\1/')
echo "latest_version=$version" >> "$GITHUB_ENV"
# check that tag version is different from `latest` version
- name: 🧮 Compare version
run: |
if [[ "$tag_version" == "$latest_version" ]]; then
echo "Error: Tag version is the same as latest version"
exit 1
else
echo "Tag version ($tag_version) is different from latest version ($latest_version)"
fi
# Build docs
- name: 📚 Build Docs
run: |
pip install -U pip
pip install -r requirements.txt
# update latest version to the tag with mike, retitle the versions
- name: 🚀 Deploy with mike
run: |
mike retitle $latest_version $latest_version
mike deploy --push '$tag_version' latest