-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (97 loc) · 3.9 KB
/
deploy.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
# This is a basic workflow to help you get started with Actions
name: deploy
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
paths:
- 'markdown/**'
- 'deploy/**'
- '.github/**'
pull_request:
branches: [ "main" ]
paths:
- 'markdown/**'
- 'deploy/**'
- '.github/**'
# 每周日0点构建
schedule:
- cron: "0 0 * * 0"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
lfs: 'true'
# 部署 node.js
- uses: actions/[email protected]
with:
node-version: lts/*
# 部署 pandoc
- name: Setup pandoc
uses: nikeee/setup-pandoc@master
# 部署 yq
- name: Setup yq
run: sudo snap install yq
# 部署 SSH 认证
- name: Config SSH
env:
ACTION_DEPLOY_KEY: ${{ secrets.HEXO_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$ACTION_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.email "[email protected]"
git config --global user.name "smilelc3"
# 部署 Go
- name: Setup Go
uses: actions/setup-go@v5
# 部署 wasm
- name: Setup wasm
run: |
mkdir cd ${{github.workspace}}/js && cd ${{github.workspace}}/js/
git clone --depth=1 https://github.com/smilelc3/MyLittleTool.git
sudo apt install emscripten -y
cd MyLittleTool
emcc Hex2Ascii.cpp Ascii2Hex.cpp Linear11Trans.cpp checksum_byteacc.cpp -D WASM_EMCC -o MyLittleTool.js -O3 -flto -s WASM=1 -s EXPORTED_FUNCTIONS='["_malloc", "_free"]' -s "EXPORTED_RUNTIME_METHODS=['cwrap']" -s ALLOW_MEMORY_GROWTH -s ASSERTIONS=1
cd ..
mv MyLittleTool/MyLittleTool.js . && mv MyLittleTool/MyLittleTool.wasm .
rm -r MyLittleTool
git clone --depth=1 https://github.com/smilelc3/sudoku-solver.git
cd sudoku-solver
GOOS=js GOARCH=wasm go build -o sudoku.wasm wasm_main.go
cd ..
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" . && mv sudoku-solver/sudoku.wasm .
rm -r sudoku-solver
# 构建和部署 hexo
- name: build and deploy hexo
run: |
npm install hexo-cli
export PATH="$PATH:./node_modules/.bin"
hexo init "blog"
cd blog
npm install
npm install hexo-theme-next
npm install hexo-deployer-git
npm uninstall hexo-renderer-marked
npm install hexo-renderer-pandoc
npm install hexo-symbols-count-time
npm install hexo-generator-searchdb
# 定制化和复制博客
bash ${{github.workspace}}/deploy/_config.yml_modify.sh $(pwd)/_config.yml
cp ./node_modules/hexo-theme-next/_config.yml ./_config.next.yml && bash ${{github.workspace}}/deploy/_config.next.yml_modify.sh $(pwd)/_config.next.yml
rm ./source/_posts/* -rf && cp ${{github.workspace}}/markdown/* ./source/_posts/
cp ${{github.workspace}}/deploy/CNAME ./source/
mkdir ./source/js && cp ${{github.workspace}}/js/* ./source/js/
hexo clean
hexo deploy --generate