简介
自己的博客一直是使用github的action去做编译的,然后发布到vercel。为了这个自己写了两个action来支持。一个是hexo build的插件,一个是dingding通知的插件,下面是地址
https://github.com/bboysoulcn/hexo-deploy
https://github.com/bboysoulcn/dingding-alert-action
使用方法
先来看我博客的ci.yaml
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另外一个仓库上
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 编译之后静态文件的位置
编译并且推送完成之后就会有一个告警的过程
也就是下面
# 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