-
Notifications
You must be signed in to change notification settings - Fork 41
147 lines (135 loc) · 4.22 KB
/
doc_to_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
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
name: Generate pages from doc
on:
workflow_call:
inputs:
source: # id of input
description: "Path to doc folder"
required: false
default: "./doc/"
type: string
destination:
description: "Path to output generated site"
required: false
default: "./_site/"
type: string
baseurl:
description: "baseurl of generated site"
required: false
default: ""
type: string
deploy:
description: "Whether to save generated site as artifact"
required: false
default: true
type: boolean
force_regen:
description: "Force regenerate"
required: false
default: false
type: string
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
# concurrency:
# group: ${{ inputs.baseurl }}
# cancel-in-progress: true
jobs:
# only rebuild if files under doc/ folder changed
check:
runs-on: ubuntu-latest
outputs:
doc_changed: ${{ steps.doc_changed.outputs.doc }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git branch
- uses: dorny/paths-filter@v2
id: doc_changed
with:
list-files: shell
# base: develop
# ref: develop
filters: |
doc:
- 'doc/**'
- '.github/workflows/doc_to_pages.yml'
- '.github/workflows/publish_doc.yml'
- name: Doc changed result is ${{ steps.doc_changed.outputs.doc }}
run: |
echo ${{ steps.doc_changed.outputs.doc }}
echo ${{ steps.doc_changed.outputs.doc == 'true' }}
- name: Force regen is ${{ inputs.force_regen == 'true' }}
run: |
echo ${{ inputs.force_regen }}
echo ${{ inputs.force_regen == 'true' }}
# Build job
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
needs: check
if: ${{ ( needs.check.outputs.doc_changed == 'true' ) || ( inputs.force_regen == 'true' ) }}
steps:
- run: |
echo needs.check.outputs.doc_changed == 'true'
echo ${{ needs.check.outputs.doc_changed == 'true' }}
echo inputs.force_regen
echo ${{ inputs.force_regen }}
echo inputs.force_regen == 'true'
echo ${{ inputs.force_regen == 'true' }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0" # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
cache-version: 1 # Increment this number if you need to re-download cached gems
working-directory: ${{ inputs.source }}
- name: Jekyll build
run: |
git branch
dst=$(pwd)/${{ inputs.destination }}
# tree .
cd ${{ inputs.source }}
pwd
python prepare.py ${{ inputs.baseurl }} # insert headers, change md relative link path to html ...
bundle exec jekyll build \
--config ./CN/_config.yml \
--source ./CN/ \
--destination $dst/CN/ \
--baseurl ${{ inputs.baseurl }}CN/
bundle exec jekyll build \
--config ./EN/_config.yml \
--source ./EN/ \
--destination $dst/EN/ \
--baseurl ${{ inputs.baseurl }}EN/
cp -s $dst/CN/index.html $dst/
# tree $dst
cd -
- name: Upload artifact
uses: actions/upload-pages-artifact@v1 # This will automatically upload an artifact from the '/_site' directory
with:
path: ${{ inputs.destination }}
retention-days: 7
# Deployment job
deploy:
needs: build
if: inputs.deploy
environment:
name: github-pages
url: steps.deployment.outputs.page_url
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1