0%

Github Actions部署hexo

使用Github Actions自动部署hexo博客

创建令牌

创建令牌

设置令牌

CODING_TOKEN的格式是令牌用户名:令牌

设置令牌

修改_config.yml

_config.yml
1
2
3
4
5
deploy:
type: git
name: star2000
email: i@star2000.work
repo: https://CODING_TOKEN@e.coding.net/xing2000/blog/deploy

创建.github/workflows/deploy.yml

.github/workflows/deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
on: push

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
submodules: true
- name: 恢复上次修改时间
run: git ls-files -z | while read -d '' path; do touch -d "$(git log -1 --format="@%ct" "$path")" "$path"; done
- uses: actions/setup-node@master
with:
node-version: "*"
- name: 部署
run: |
sed -i "s|CODING_TOKEN|${{ secrets.CODING_TOKEN }}|" _config.yml
npm i --production
npm run deploy

欢迎关注我的其它发布渠道