forked from tier4/AutowareArchitectureProposal.iv
-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (104 loc) · 3.25 KB
/
generate-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
name: Generate documentation
on:
push:
branches:
- main
- develop
paths:
- "mkdocs.yml"
- "**/*.md"
- "**/*.svg"
- "**/*.png"
- "**/*.css"
pull_request:
paths:
- "mkdocs.yml"
- "**/*.md"
- "**/*.svg"
- "**/*.png"
- "**/*.css"
workflow_dispatch:
env:
GITHUB_PAGES_URL: https://tier4.github.io/autoware.iv
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Fetch with depth=0 to calculate modified files
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install MkDocs
run: |
python3 -m pip install --upgrade pip setuptools wheel
pip3 install \
fontawesome_markdown \
markdown \
mdx_truly_sane_lists \
mdx_unimoji \
mkdocs \
mkdocs-exclude \
mkdocs-material \
mkdocs-same-dir \
plantuml-markdown \
pymdown-extensions \
python-markdown-math
- name: Remove non-document files
run: |
find . -type f \
-not -path './.git/*' \
-not -path './.github/*' \
-not -path './mkdocs.yml' \
-not -name '*.md' \
-not -name '*.svg' \
-not -name '*.png' \
-not -name '*.css' \
| xargs -I {} rm "{}"
- name: Build MkDocs
run: |
mkdocs build -f mkdocs.yml --verbose --clean
- name: Move docs (push)
if: ${{ !github.event.pull_request }}
run: |
mkdir -p public/tree
mv site public/tree/${GITHUB_REF#refs/heads/}
- name: Move docs (pull_request)
if: ${{ github.event.pull_request }}
run: |
mkdir -p public/pulls
mv site public/pulls/${{ github.event.pull_request.number }}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true
- name: Create comment body
if: ${{ github.event.pull_request }}
id: create_comment_body
run: |
base_url="${{ env.GITHUB_PAGES_URL }}/pulls/${{ github.event.pull_request.number }}/"
${GITHUB_WORKSPACE}/.github/create_doc_comment.sh "${base_url}" "origin/${{ github.event.pull_request.base.ref }}"
- name: Find Comment
if: ${{ github.event.pull_request }}
id: find_comment
uses: peter-evans/find-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Documentation
- name: Comment PR
if: ${{ github.event.pull_request }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}
body: |
${{ steps.create_comment_body.outputs.comment_body }}
edit-mode: replace