-
Notifications
You must be signed in to change notification settings - Fork 40
63 lines (54 loc) · 2.08 KB
/
automatic-docs-update.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
name: Automatic docs update pipeline
on:
issue_comment:
types: [created, edited]
# Run when PR is labeled
pull_request:
types: [labeled]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
pull-requests: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build-and-publish:
name: Automatically update docs
if: ${{ (github.event.issue.pull_request && contains(github.event.comment.body, '/refresh-docs')) || github.event.label.name == 'refresh-docs' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up git author
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NOTE: the pipeline will fail, if gh-pages branch isn't created!!!
- name: Git fetch gh-pages
run: git fetch origin gh-pages
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Retrieve latest version tag
run: |
LATEST_VERSION=$(mike list | grep [latest] | awk '{sub(/\[latest\]/, ""); print}')
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
# this is only possible, when there is already a version with latest alias
# in case there isn't a version like this you have to
# 1. mike deploy <version> latest
# 2. mike set-default latest
# 3. mike deploy <version_from_cmd_1> latest --push
# --push flag in the latest cmd is necessary, when you want to apply changes in gh-pages branch and also in GH Pages
- name: Deploy new docs version
run: mike deploy ${LATEST_VERSION} latest --update-aliases --push