Skip to content

Commit 3b0509a

Browse files
author
shenliyang
committed
chore: 新增github actions
1 parent ef3ba87 commit 3b0509a

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Github Actions For Hexo Auto Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
workflow_dispatch:
8+
9+
env:
10+
GIT_USER: shenliyang
11+
GIT_EMAIL: 14257483+shenliyang@users.noreply.github.com
12+
GIT_DEPLOY_REPO: shenliyang/shenliyang.github.io
13+
GIT_DEPLOY_BRANCH: master
14+
15+
GITEE_USER: shenliyang
16+
GITEE_DEPLOY_REPO: shenliyang/shenliyang
17+
GITEE_DEPLOY_BRANCH: master
18+
19+
GIT_SOURCE_REPO: git@github.com:shenliyang/shenliyang.github.io.git
20+
GITEE_DESTINATION_REPO: git@gitee.com:shenliyang/shenliyang.git
21+
22+
jobs:
23+
build:
24+
name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
25+
runs-on: ubuntu-latest
26+
if: github.event.repository.owner.id == github.event.sender.id
27+
strategy:
28+
matrix:
29+
os: [ubuntu-18.04]
30+
node_version: [12.x]
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v2
35+
36+
- name: Checkout deploy repo
37+
uses: actions/checkout@v2
38+
with:
39+
repository: ${{ env.GIT_DEPLOY_REPO }}
40+
ref: ${{ env.GIT_DEPLOY_BRANCH }}
41+
path: .deploy_git
42+
43+
- name: Use Node.js ${{ matrix.node_version }}
44+
uses: actions/setup-node@v1
45+
with:
46+
node-version: ${{ matrix.node_version }}
47+
48+
- name: Configuration environment
49+
env:
50+
HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}}
51+
run: |
52+
sudo timedatectl set-timezone "Asia/Shanghai"
53+
mkdir -p ~/.ssh/
54+
echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa
55+
chmod 600 ~/.ssh/id_rsa
56+
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
57+
# ssh-keyscan -t rsa gitee.com >> ~/.ssh/known_hosts
58+
git config --global user.name $GIT_USER
59+
git config --global user.email $GIT_EMAIL
60+
61+
- name: Install dependencies
62+
run: |
63+
npm install hexo-cli gulp hexo-deployer-git -g
64+
npm install
65+
hexo clean && hexo g
66+
gulp
67+
68+
# - name: info
69+
# run: |
70+
# ./deploy.sh
71+
72+
- name: Deploy hexo
73+
run: |
74+
npm run deploy
75+

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ notifications:
2020
# 邮件发送部署结果通知
2121
email:
2222
recipients:
23-
- snippet@aliyun.com
23+
- 14257483+shenliyang@users.noreply.github.com
2424
on_success: change
2525
on_failure: always
2626

0 commit comments

Comments
 (0)