-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (120 loc) · 4.36 KB
/
docs.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
name: Generate documentation for nightly
on:
push:
branches:
- "master"
- "docs"
paths-ignore:
- "README.md"
- "CHANGES.md"
- LICENCE
- .git*
- .editorconfig
workflow_dispatch:
jobs:
deploy-documentation-for-master:
runs-on: "ubuntu-latest"
name: "Generate documentation for nightly"
steps:
- uses: actions/checkout@v2
with:
ref: docs
fetch-depth: 0 # fetch all commits/branches
- uses: actions/setup-python@v2
with:
python-version: 3.x
- uses: actions/cache@v2
name: "Cache Python dependencies (mkdocs-material and mike)"
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: pip install -r requirements.txt
- name: Add git user for mike
run: |
git config --global user.name GitHub Actions
git config --global user.email [email protected]
- name: "Deploy documentation for nightly"
run: mike deploy v0.2.0 nightly master --push
# TODO add some way of skipping this step when it has already been done
# in previous commits.
- name: "Label development version with -dev suffix"
run: mike retitle v0.2.0 v0.2.0-dev --push
add_crystal_api_docs_versions_file:
runs-on: "ubuntu-latest"
needs: deploy-documentation-for-master
name: "Deploy Crystal API versions file"
steps:
# First we checkout the deploy branch and check
# if we even need to deploy a new versions file
- uses: actions/checkout@v2
with:
ref: gh-pages
# Get hash
- name: Hash deployed cry-versions.json
id: "hash-deployed-version-json"
run: echo "::set-output name=hashed::${{ hashFiles('cry-versions.json') }}"
# Now we head on over to the docs branch
# and check if we need to update the deployed versions.json
- uses: actions/checkout@v2
with:
ref: docs
- name: Should we update cry-versions.json?
id: version-comparison
run: |
if [[ ${{steps.hash-deployed-version-json.outputs.hashed}} == ${{hashFiles('cry-versions.json')}} ]]; then
echo ::set-output name=exit_code::1
fi
- if: ${{steps.version-comparison.outputs.exit_code }} != 1
name: "Copy cry-versions.json"
run: "cp cry-versions.json ../"
- if: ${{steps.version-comparison.outputs.exit_code }} != 1
uses: actions/checkout@v2
with:
ref: gh-pages
- if: ${{steps.version-comparison.outputs.exit_code }} != 1
name: "Replace cry-versions.json"
run: "mv ../cry-versions.json ."
- if: ${{steps.version-comparison.outputs.exit_code }} != 1
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update cry-versions.cr
deploy-api-documentation-for-master:
needs: add_crystal_api_docs_versions_file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Install Crystal
uses: crystal-lang/[email protected]
with:
crystal: 1.2.0
- name: Cache Shards
uses: actions/cache@v2
with:
path: ./lib
key: shards-${{ hashFiles('shard.lock') }}
- name: Install Shards
run: |
if ! shards check; then
shards install
fi
- name: Build API docs
run: |
crystal docs --json-config-url=/lens/cry-versions.json --output=api --project-version=v0.2.0-dev --project-name=Lens \
--canonical-base-url="https://syeopite.github.io/lens/api/latest" --source-url-pattern="https://github.com/syeopite/lens/blob/%{refname}/%{path}#L%{line}" \
--source-refname=${GITHUB_SHA::8}
- name: Deploy API docs
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: api
target-folder: api/master
clean: false
commit-message: "Update API documentation for nightly"