Github持续部署测试

本篇文章使用Github Action部署,通过配置.github/workflows/deploy.yml,实现推送Markdown文件后,文章内容自动发布到仓库。

如果可以看到这篇文章,则说明Github Action正确配置。

.github/workflows/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
name: Hexo Deploy

on:
push:
branches:
- main

jobs:
build-deploy:
runs-on: ubuntu-latest

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

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '22'

- name: Install Dependencies
run: |
npm install hexo-cli -g
npm install

- name: Remove unnessary Dependency
run: npm uninstall hexo-generator-index

- name: Generate Files
run: npx hexo generate

- name: Configure Git
run: |
git config --global user.name "${{ vars.GIT_USERNAME }}"
git config --global user.email "${{ vars.GIT_EMAIL }}"

- name: Setup SSH
run: |
mkdir ~/.ssh
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

- name: Deploy
run: npx hexo deploy