-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (47 loc) · 1.27 KB
/
publish.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
name: Publish to gh-pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
- run: npm install
- run: npm run build
- name: Publish
run: |
# Create a temporary directory
export temp_dir=`mktemp -d -p ~`
(
# Preserve .git
mkdir $temp_dir/temp
mv .git $temp_dir/temp
cd $temp_dir/temp
# Switch branch
git fetch
git checkout gh-pages
git reset --hard gh-pages
)
(
# Move .git
mv $temp_dir/temp/.git $temp_dir
rm -rf $temp_dir/temp
mv public/* $temp_dir
mv LICENSE $temp_dir
# Go to the temporary directory
cd $temp_dir
# Set commit identity
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# Publish
git add .
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Publish `TZ='Asia/Hong_Kong' date`"
git push -f origin gh-pages
fi
)