Skip to main content

此版本的 GitHub Enterprise Server 将于以下日期停止服务 2025-08-27. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Workflows

Get a high-level overview of GitHub Actions workflows, including triggers, syntax, and advanced features.

About workflows

工作流是一个可配置的自动化过程,它将运行一个或多个作业。 工作流程由签入到存储库的 YAML 文件定义,并在存储库中的事件触发时运行,也可以手动触发,或按定义的时间表触发。

工作流在仓库的 .github/workflows 目录中定义。 一个仓库可以有多个工作流,每个工作流都可以执行一组不同的任务,例如:

  • 构建和测试拉取请求
  • 在每次创建发布时,部署应用程序
  • 每当创建新提议时,添加标签

Workflow basics

A workflow must contain the following basic components:

  1. One or more events that will trigger the workflow.
  2. One or more jobs, each of which will execute on a runner machine and run a series of one or more steps.
  3. Each step can either run a script that you define or run an action, which is a reusable extension that can simplify your workflow.

For more information on these basic components, see Understanding GitHub Actions.

Diagram of an event triggering Runner 1 to run Job 1, which triggers Runner 2 to run Job 2. Each of the jobs is broken into multiple steps.

Workflow triggers

工作流程触发器是导致工作流程运行的事件。 这些事件可以是:

  • 工作流程存储库中发生的事件
  • 在 GitHub 外部发生并在 GitHub 上触发 repository_dispatch 事件的事件
  • 预定时间
  • 手动

例如,您可以将工作流程配置为在推送到存储库的默认分支、创建发行版或打开议题时运行。

For more information, see 触发工作流程.

Next steps

To build your first workflow, see Creating an example workflow.