0

发布两个github的action

 3 years ago
source link: https://www.bboy.app/2021/08/09/%E5%8F%91%E5%B8%83%E4%B8%A4%E4%B8%AAgithub%E7%9A%84action/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

发布两个github的action

发表于

2021-08-09 更新于 2021-08-14 分类于 linux

202108090953552.png

自己的博客一直是使用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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK