-
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (170 loc) · 6.18 KB
/
docs-workflow.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#
# This GitHub Actions workflow builds and deploys the re-frame documentation website hosted on GitHub Pages at:
# https://day8.github.io/re-frame/
#
# More about the build process are documented at
# https://github.com/day8/re-frame/blob/feature/mkdocs/docs/developer-notes.md
name: docs
on:
push:
branches: 'master'
jobs:
# The ns-to-markdown job generates API documentation from the source code and uploads that as an artifact.
ns-to-markdown:
name: re-frame.core Markdown
runs-on: ubuntu-20.04
container:
# Source: https://github.com/day8/dockerfiles-for-dev-ci-images
image: ghcr.io/day8/chrome-56:2
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Current Branch
uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git config --system --add safe.directory /__w/re-frame/re-frame
- name: Build re-frame.core Documentation
working-directory: docs
# Source: https://github.com/day8/re-frame/blob/master/docs/src/ns_to_markdown.clj
run: clojure -m ns-to-markdown ../src/re_frame/core.cljc > api-re-frame.core.md
- name: Build re-frame.alpha Documentation
working-directory: docs
# Source: https://github.com/day8/re-frame/blob/master/docs/src/ns_to_markdown.clj
run: clojure -m ns-to-markdown ../src/re_frame/alpha.cljc > api-re-frame.alpha.md
- name: Upload re-frame.core Documentation Artifact
uses: actions/upload-artifact@v2
with:
name: api-re-frame.core.md
path: docs/api-re-frame.core.md
- name: Upload re-frame.alpha Documentation Artifact
uses: actions/upload-artifact@v2
with:
name: api-re-frame.alpha.md
path: docs/api-re-frame.alpha.md
# This job builds the re-frame :docs app and uploads it as an artifact.
# The app renders code blocks for the reader reader to edit & evaluate.
re-frame-docs-app:
name: Re-frame Docs App
runs-on: ubuntu-20.04
container:
image: ghcr.io/day8/dockerfile-for-dev-ci-image/dev-ci:1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Current Branch
uses: actions/checkout@v2
- run: git config --system --add safe.directory /__w/re-frame/re-frame
- name: Maven cache
id: maven-cache
uses: actions/cache@v1
with:
path: /root/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj', '.github/workflows/**') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Install node packages
run: |
npm install
- name: Run lein docs
if: steps.maven-cache.outputs.cache-hit != 'true'
env:
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
lein docs
- name: Run lein -o docs
if: steps.maven-cache.outputs.cache-hit == 'true'
env:
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
CLOJARS_TOKEN: ${{ secrets.CLOJARS_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
lein -o docs
- name: Create re-frame-docs App Artifact
working-directory: docs
run: |
tar Jcf re-frame-docs-app.tar.xz js
- name: Upload re-frame-docs App Artifact
uses: actions/upload-artifact@v2
with:
name: re-frame-docs-app
path: docs/re-frame-docs-app.tar.xz
# MkDocs is the actual static site generator. It downloads the api-re-frame.core.md and docs app artifacts,
# then generates additional files based on configuration and markdown.
mkdocs:
name: MkDocs
needs:
- ns-to-markdown
- re-frame-docs-app
runs-on: ubuntu-22.04
container:
image: "squidfunk/mkdocs-material:5.5.9"
steps:
- name: Checkout Current Branch
uses: actions/checkout@v2
- run: git config --system --add safe.directory /__w/re-frame/re-frame
- name: Download api-re-frame.core.md Artifact
uses: actions/download-artifact@v2
with:
name: api-re-frame.core.md
path: docs
- name: Download api-re-frame.alpha.md Artifact
uses: actions/download-artifact@v2
with:
name: api-re-frame.alpha.md
path: docs
- name: Download re-frame-docs App Artifact
uses: actions/download-artifact@v2
with:
name: re-frame-docs-app
path: docs
- name: Extract re-frame-docs App Artifact
working-directory: docs
run: tar Jxf re-frame-docs-app.tar.xz
- name: Build MkDocs Documentation
run: mkdocs build
- name: Create MkDocs Artifact
run: tar zcf mkdocs.tar.gz site/
- name: Upload MkDocs Artifact
uses: actions/upload-artifact@v1
with:
name: mkdocs
path: mkdocs.tar.gz
# The GitHub Pages job downloads the final MkDocs artifact and commits it to the gh-pages branch for deployment.
github-pages:
name: GitHub Pages
needs: mkdocs
runs-on: ubuntu-20.04
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v2
with:
ref: "gh-pages"
path: "gh-pages"
- name: Download MkDocs Artifact
uses: actions/download-artifact@v1
with:
name: mkdocs
- name: Extract MkDocs Artifact
run: |
tar zxf mkdocs/mkdocs.tar.gz
rm -rf gh-pages/*
cp -Rv site/* gh-pages/
- name: Commit
working-directory: ./gh-pages
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Update docs"
- name: Push
working-directory: ./gh-pages
run: |
REMOTE="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${REMOTE}" HEAD:gh-pages