-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (55 loc) · 2 KB
/
main.yml
File metadata and controls
64 lines (55 loc) · 2 KB
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
on:
# Triggers the workflow on push or pull request events but only for the main branch
push: # push的时候触发
branches: [ main ] # 哪些分支需要触发
# 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@v1
with:
node-version: 'v12.16.2'
- name: Cache node modules
# 设置包缓存目录,避免每次下载
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# 配置Hexo环境
- name: Setup Hexo
env:
ACTION_DEPLOY_KEY: ${{ secrets.ACCESS_TOKEN }}
run: |
npm install hexo-cli -g
npm install
npm update
# 生成静态文件
- name: Build
run: |
hexo clean
hexo g
# 2、部署到 GitHub Pages
- name: upload GitHub repository
env:
# Github 仓库
GITHUB_REPO: github.com/Superego-CodeEngineer/Superego-CodeEngineer.github.io
run: |
cd ./public && git init && git add .
git branch -m master main
git config user.name "opensource-contrib"
git config user.email "opensource-contrib@outlook.com"
git add .
git commit -m "GitHub Actions Auto Builder at $(date +'%Y-%m-%d %H:%M:%S')"
git push --force --quiet "https://${{ secrets.ACCESS_TOKEN }}@$GITHUB_REPO" main:main