Github Action
是 Github 官方的 CICD 工具,你可以在 Github Action
中做,单元测试、代码编译、发布、部署等动作,是 Github 的利器。
简介
With GitHub Actions you can automate your workflow from idea to production.
官网
本人开源的Actions
代码托管在x-actions,说明:
Actions 开发文档
语法
icon
默认变量
推荐的 Actions
本地模拟
brew install act
# 本地运行
act
# 列出actions
act -l
action 时区
sudo timedatectl set-timezone "Asia/Shanghai"
demo
- name: Cancel previous runs on the same branch
if: ${{ github.ref != 'refs/heads/master' }}
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Hook Update workflow
run: |
curl -XPOST -H "Authorization: token ${{ secrets.WORKFLOW_TRIGGERS }}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/xiexianbin/xiexianbin.github.io/actions/workflows/deploy.yml/dispatches
添加手动触发工作流
手动工作流,通过 on.workflow_dispatch
字段指定,需要将代码何如 main or master
分支才生效。
on:
...
workflow_dispatch:
inputs:
reason:
description: 'run action reason'
required: false
type: string
default: 'manually test'