-
-
Notifications
You must be signed in to change notification settings - Fork 82
120 lines (96 loc) · 4.11 KB
/
gh-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
# see https://squidfunk.github.io/mkdocs-material/setup/setting-up-versioning/
# execute once, after the first deployment has 'latest' as alias:
# mike set-default latest --push
name: Documentation
on:
push:
branches:
- develop
paths:
- 'mkdocs.yml'
- 'sootup.examples/**'
- 'docs/**'
- '.github/workflows/gh-pages.yml'
release:
types: [ created, published ]
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths:
- 'mkdocs.yml'
- 'sootup.examples/**'
- 'docs/**'
- '.github/workflows/gh-pages.yml'
concurrency: pages
permissions:
contents: write
pull-requests: write
jobs:
manage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# to get tag information
- run: git fetch --prune --unshallow
- uses: actions/setup-python@v2
with:
python-version: 3.x
# install dependencies
- run: pip install mike
- run: pip install mkdocs-material
- run: pip install mkdocs-tooltips
- run: pip install git+https://github.com/RedisLabs/mkdocs-include.git
- run: pip install git+https://github.com/swissiety/LspLexer4Pygments.git
# grab latest release url of the JimpleLSP jar and download it
- run: curl -s -L -o ./jimplelsp.jar $(curl -s https://api.github.com/repos/swissiety/jimpleLsp/releases/latest | grep 'browser_download_url".*jar"' | cut -d ':' -f 2,3 | tr -d \")
- name: replace "{{ git_latest_release }}" with latest release tag version in .md files
run: sed -i 's\{{ git_latest_release }}\'$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1 | cut -b 2-7)'\g' docs/**.md
- run: git fetch origin gh-pages --depth=1
- name: Configure git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# sanitive head_ref name
- run: echo DOC_VERSION_NAME="test_preview" >> "$GITHUB_ENV"
- run: echo $DOC_VERSION_NAME;
- run: echo "$DOC_VERSION_NAME";
- run: echo "$DOC_VERSION_NAME_preview";
- run: echo "$DOC_VERSION_NAME"_preview;
- run: echo ${DOC_VERSION_NAME};
- run: echo ${DOC_VERSION_NAME}_preview;
# on push to develop branch - keep a doc around for develop to show the current state
- name: deploy doc in subdirectory
if: github.event_name == 'push'
run: mike deploy develop
# on PR events..
- name: deploy doc in subdirectory
if: github.event_name == 'pull_request'
run: mike deploy "$DOC_VERSION_NAME"_preview --push
# TODO: set to true when the release is capable of the documentation ;) && mike props "$DOC_VERSION_NAME"_preview --set-string hidden=true --push
- name: comment link to preview
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
You updated the documentation - [Doc Preview](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"$DOC_VERSION_NAME"_preview/).
# on PR close - delete preview
- name: delete the deployed preview
if: github.event_name == 'pull_request' && github.event.action == 'closed'
run: mike delete "$DOC_VERSION_NAME"_preview --push
# on release events..
# sanitive head_ref name
- name: sanitize tag name
if: github.event_name == 'release'
run: echo "DOC_VERSION_NAME=${${{github.ref_name}}//[^[:alnum:]]/_}" >> "$GITHUB_ENV"
- name: deploy doc in subdirectory
if: github.event_name == 'release'
run: mike deploy "$DOC_VERSION_NAME" --push
- name: deploy doc in subdirectory
if: github.event_name == 'release'
run: mike deploy "$DOC_VERSION_NAME" --push
- name: set the new release doc as default (release published)
if: github.event_name == 'release' && github.event.action == 'published'
run: mike deploy --push --update-aliases "$DOC_VERSION_NAME" latest