发布两个github的action

简介

自己的博客一直是使用github的action去做编译的,然后发布到vercel。为了这个自己写了两个action来支持。一个是hexo build的插件,一个是dingding通知的插件,下面是地址

https://github.com/bboysoulcn/hexo-deploy

https://github.com/bboysoulcn/dingding-alert-action

使用方法

先来看我博客的ci.yaml

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
name: ci
on:
push:
branches:
- master
jobs:
build-and-deploy-image:
runs-on: ubuntu-latest
steps:
# 拉取master分支
- name: Checkout
uses: actions/checkout@master
# 编译
- name: Build and Deploy
uses: bboysoulcn/hexo-deploy@main
env:
PERSONAL_TOKEN: ${{ secrets.PUSH_TOKEN }}
PUBLISH_REPOSITORY: bboysoulcn/bboysoulcn.github.io # The repository the action should deploy to.
BRANCH: master # The branch the action should deploy to.
PUBLISH_DIR: ./public # The folder the action should deploy.

# dingtalk alert
- name: dingtalk alert success
uses: bboysoulcn/dingding-alert-action@main
if: ${{ success() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译成功"

- name: dingtalk alert failed
uses: bboysoulcn/dingding-alert-action@main
if: ${{ failure() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译失败"

- name: dingtalk alert cancelled
uses: bboysoulcn/dingding-alert-action@main
if: ${{ cancelled() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译退出"

首先使用actions/checkout@master拉取主分支,之后使用bboysoulcn/hexo-deploy@main去编译,并且把编译出来的静态文件推送到github另外一个仓库上

1
2
3
4
PERSONAL_TOKEN: ${{ secrets.PUSH_TOKEN }}
PUBLISH_REPOSITORY: bboysoulcn/bboysoulcn.github.io # The repository the action should deploy to.
BRANCH: master # The branch the action should deploy to.
PUBLISH_DIR: ./public # The folder the action should deploy.

PERSONAL_TOKEN就是推送到仓库的token,PUBLISH_REPOSITORY定义了推送到哪一个token,BRANCH表示推送的分支,PUBLISH_DIR就是hexo 编译之后静态文件的位置

编译并且推送完成之后就会有一个告警的过程

也就是下面

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
# dingtalk alert
- name: dingtalk alert success
uses: bboysoulcn/dingding-alert-action@main
if: ${{ success() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译成功"

- name: dingtalk alert failed
uses: bboysoulcn/dingding-alert-action@main
if: ${{ failure() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译失败"

- name: dingtalk alert cancelled
uses: bboysoulcn/dingding-alert-action@main
if: ${{ cancelled() }}
env:
DING_SECRET: ${{secrets.DING_SECRET}}
DING_BASE_URL: ${{secrets.DING_BASE_URL}}
TITLE: "github 博客编译提醒"
MSG: "博客编译退出"

if: ${{ cancelled() }} 就是流水线的状态

${{secrets.DING_SECRET}} dingding的secret

${{secrets.DING_BASE_URL}} dingding的推送地址

欢迎关注我的博客www.bboy.app

Have Fun

欢迎关注我的其它发布渠道