forked from OI-wiki/OI-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (113 loc) · 3.67 KB
/
build.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
name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
build:
name: OI-Wiki Page Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pipenv
- uses: actions/setup-node@v4
with:
node-version: '20.x'
check-latest: true
- name: Install Python dependencies
run: |
pip install pipenv
pipenv install
- name: Cache Node.js dependencies
uses: actions/cache@v4
id: cache-node
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-node-
- name: Install Node.js dependencies
if: steps.cache-node.outputs.cache-hit != 'true'
run: yarn --frozen-lockfile --production
- name: Page Build
run: |
./scripts/pre-build/pre-build.sh
pipenv run mkdocs build -v
- name: Post-process HTML
# https://github.com/TypeStrong/ts-node/issues/1997
run: node --loader ts-node/esm scripts/post-build/html-postprocess.ts commits-info math external-links
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=3072
- name: Minify html
run: ./scripts/post-build/minify-html/minify-html.sh
- name: Generate redirects
run: pipenv run python scripts/post-build/redirect/generate-redirects.py
- name: Check links
uses: wjdp/htmltest-action@master
with:
skip_external: true
- name: Fetch old site
uses: actions/checkout@v4
with:
ref: gh-pages
path: old-site
- name: Check _redirects
run: pipenv run python scripts/post-build/redirect/check-redirects.py
- name: Deploy to gh-pages
if: ${{ github.event_name == 'push' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
force_orphan: true
- name: Push to Baidu
if: ${{ github.event_name == 'push' && github.repository_owner == 'oi-wiki' }}
env:
SITE: oi-wiki.org
BAIDU_TOKEN: ${{ secrets.BaiduToken }}
run: ./scripts/post-deploy/baidu-push.sh
update_feedback_sys_meta:
name: Update OI-Wiki Feedback System Meta
needs: build
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout latest
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
uses: tj-actions/changed-files@v44
with:
files: docs/**/*.md
base_sha: ${{ github.event.before }}
sha: ${{ github.event.after }}
include_all_old_new_renamed_files: true
write_output_files: true
- name: Checkout before
uses: actions/checkout@v4
with:
ref: ${{ github.event.before }}
path: before
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
pip install pipenv
pipenv install
- name: Update meta
run: |
pipenv run python scripts/update-feedback-sys-meta.py --modified .github/outputs/modified_files.txt --renamed .github/outputs/all_old_new_renamed_files.txt --before_dir before
env:
ADMINISTRATOR_SECRET: ${{ secrets.FEEDBACK_SYS_ADMINISTRATOR_SECRET }}