Github Action 使用介绍

发布时间: 更新时间: 总字数:412 阅读时间:1m 作者: IP属地: 分享 复制网址

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

本地模拟

  • nektos/act 项目
  • 安装
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'
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数