-
Notifications
You must be signed in to change notification settings - Fork 57
93 lines (85 loc) · 2.77 KB
/
gh-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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Jekyll
on:
- push
- pull_request
jobs:
test:
name: Test & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # https://github.com/facebook/docusaurus/issues/2798#issuecomment-636602951
- name: Bundle Config
run: |
sudo gem install bundler
- uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: package.json
- name: NPM Install
run: npm install
- name: Debug
run: |
git log --since="1 week ago" --name-only --pretty=format: | sort | uniq
git log --since="1 week ago" --name-only --pretty=format: | sort | uniq | wc -l
- name: NPM Test
run: npm test
- name: Install Dependencies
run: make install
- name: Build
run: npm run build
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Deploy GitHub Pages
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # https://github.com/facebook/docusaurus/issues/2798#issuecomment-636602951
- name: Bundle Cache Config
run: |
sudo gem install bundler
# bundle config path ~/.npm/bundle
- uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
cache-dependency-path: package.json
- name: Config Git
run: |
git config --global user.name 'Huan @ GitHub Action'
git config --global user.email '[email protected]'
- name: Create orphan branch for gh-pages
run: |
git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m "Orphan init"
git checkout main
- name: Install dependencies
run: |
make install
- name: Bind git worktree with new-gh-pages folder and gh-pages branch
run: |
rm -fr new-gh-pages
git worktree add new-gh-pages gh-pages
- name: Build and copy all homepage files to new-gh-pages/ together
run: |
bash -x ./scripts/build-all.sh new-gh-pages
- name: Deploy new-gh-pages
run: |
pushd new-gh-pages
git add --all
git commit -m "$(jq -r .version ../package.json)"
git push -f origin gh-pages
popd
- name: Unbind new-gh-pages folder from gh-pages branch
run: |
git worktree remove new-gh-pages
git branch -D gh-pages
rm -fr new-gh-pages