-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 1.95 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
name: Deploy My_Blog #自动化的名称
on:
# Triggers the workflow on push or pull request events but only for the main branch
push: # push的时候触发
branches: [ source ] # 哪些分支需要触发
pull_request:
branches: [ source ]
# 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"
Blog_CI-CD:
runs-on: ubuntu-latest # 服务器环境
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# 检查代码
- name: Checkout
uses: actions/checkout@v2 #软件市场的名称
with: # 参数
submodules: true
persist-credentials: false
- name: Setup Node.js
# 设置 node.js 环境
uses: actions/setup-node@v3
with:
node-version: 'latest'
- name: Cache node modules
# 设置包缓存目录,避免每次下载
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# 安装各种插件
- name: Setup Plugin
env:
ACTION_DEPLOY_KEY: ${{ secrets.TRAVIS_CI }}
run: |
npm install hexo-cli -g
npm install hexo-deployer-git --save
npm install
# 生成静态文件
- name: Build
run: |
hexo clean
hexo g
# 2、部署到 GitHub Pages
- name: upload GitHub repository
# 将编译后的博客文件推送到指定仓库
run: |
sed -i "s/gh_token/${{ secrets.TRAVIS_CI }}/g" ./_config.yml
echo "misakatang.cn" > ./public/CNAME
cp LICENSE ./public
cp README.md ./public
git config --global user.name "misakatang"
git config --global user.email "[email protected]"
hexo deploy