使用gitaction自动部署hexo博客出错

根据使用git action自动部署的教程配置了部署配置文件(配置说明可以查看底部参考链接)

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
name: CI

on:
push:
branches:
- master

env:
GIT_USER: yinjikai
GIT_EMAIL: jackyin94@gmail.com
THEME_REPO: fluid-dev/hexo-theme-fluid
THEME_BRANCH: master
DEPLOY_REPO: yjk2022/yjk2022.github.io
DEPLOY_BRANCH: master

jobs:
build:
name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node_version: [12.x]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Checkout theme repo
uses: actions/checkout@v2
with:
repository: ${{ env.THEME_REPO }}
ref: ${{ env.THEME_BRANCH }}
path: themes/concise

- name: Checkout deploy repo
uses: actions/checkout@v2
with:
repository: ${{ env.DEPLOY_REPO }}
ref: ${{ env.DEPLOY_BRANCH }}
path: .deploy_git

- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}

- name: Configuration environment
env:
HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}}
run: |
sudo timedatectl set-timezone "Asia/Shanghai"
mkdir -p ~/.ssh/
echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
git config --global user.name $GIT_USER
git config --global user.email $GIT_EMAIL

- name: Install dependencies
run: |
npm install
- name: Deploy hexo
run: |
npm run deploy

部署后执行workflow一直报错
DmJOld.png

提示没有权限

1
2
3
4
remote: Permission to yinjikai/yinjikai.github.io.git denied to github-actions[bot]

fatal: unable to access 'https://github.com/yinjikai/yinjikai.github.io/': The requested URL returned error: 403

DmJeiD.png

继续翻阅部署文章,发现自己只配置了密钥没有调整hexo deploy配置为ssh

报错配置

DmJ0Lq.png

调整为ssh地址问题得到解决

1
2
3
4
deploy:
type: git
repo: git@github.com:yinjikai/yinjikai.github.io.git
branch: master

DmYFpQ.png

参考链接