我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

关于 GitHub 操作

GitHub 操作 enables you to create custom software development life cycle (SDLC) workflows directly in your GitHub repository.

GitHub 操作 目前为有限公测期,可能会有变动。 在公测期间,强烈建议不要将此功能用于高价值工作流程和内容。

For more information about using GitHub 操作, see "Automating your workflow with GitHub 操作."

本文内容

关于 GitHub 操作

GitHub 操作 可让您灵活地构建自动化的软件部署生命周期工作流程。您可以编写个别任务、调用的操作,以及结合它们创建自定义工作流程。 工作流程是您可以在仓库中创建的自定义自动化流程,用于在 GitHub 上构建、测试、封装、发行或部署任何代码项目。

With GitHub 操作 you can build end-to-end continuous integration (CI) and continuous deployment (CD) capabilities directly in your repository. GitHub 操作 powers GitHub's built-in continuous integration service. 更多信息请参阅“关于持续集成”。

工作流程在 GitHub 托管的服务器上的 Linux、macOS、Windows 和容器中运行。 您可以使用仓库中定义的操作、GitHub 上公共仓库中的开源操作或者发布的 Docker 容器图像来创建工作流程。 Workflows in forked repositories don't run by default.

您可以在 GitHub 上发现要用于工作流程的操作,以及创建要与 GitHub 社区共享的操作。 有关创建自定义操作的更多信息,请参阅“创建操作”。

您可以创建配置为对特定事件运行的工作流程文件。 更多信息请参阅“配置工作流程”和“GitHub 操作 的工作流程语法”。

GitHub 操作 的核心概念

这些是使用 GitHub 操作 时的一些公共术语,具有特定的含义。

工作流程

您可以在仓库中创建的可配置自动化流程,用于在 GitHub 上构建、测试、封装、发行或部署任何项目。 工作流程由一项或多项作业组成,可以计划或由事件激活。

工作流程运行

当预配置的事件发生时运行的工作流程实例。 您可以查看每个工作流程运行的作业、操作、日志和状态。

工作流程文件

定义至少有一项作业的工作流程配置的 YAML 文件。 此文件位于 GitHub 仓库根目录的 .github/workflows 目录下。

作业

A defined task made up of steps. Each job is run in a fresh instance of the virtual environment. You can define the dependency rules for how jobs run in a workflow file. Jobs can run at the same time in parallel or be dependent on the status of a previous job and run sequentially. For example, a workflow can have two sequential jobs that build and test code, where the test job is dependent on the status of the build job. If the build job fails, the test job will not run.

步骤

A step is a set of tasks performed by a job. Each step in a job executes in the same virtual environment, allowing the actions in that job to share information using the filesystem. Steps can run commands or actions.

作用

Individual tasks that you combine as steps to create a job. Actions are the smallest portable building block of a workflow. You can create your own actions, use actions shared from the GitHub community, and customize public actions. To use an action in a workflow, you must include it as a step.

Continuous integration (CI)

The software development practice of frequently committing small code changes to a shared repository. With GitHub 操作, you can create custom CI workflows that automate building and testing your code. From your repository, you can view the status of your code changes and detailed logs for each action in your workflow. CI saves developers time by providing immediate feedback on code changes to detect and resolve bugs faster.

Continuous deployment (CD)

Continuous deployment builds on continuous integration. When new code is committed and passes your CI tests, the code is automatically deployed to production. With GitHub 操作, you can create custom CD workflows to automatically deploy your code to any cloud, self-hosted service, or platform from your repository. CD saves developers time by automating the deployment process and deploys tested, stable code changes more quickly to your customers.

虚拟环境

GitHub hosts Linux, macOS, and Windows virtual environments to run your workflows.

Runner

A GitHub service in each virtual environment that waits for available jobs. When a runner picks up a job, it runs the job's actions and reports the progress, logs, and final results back to GitHub. Runners run one job at a time.

Event

A specific activity that triggers a workflow run. For example, activity can originate from GitHub when someone pushes a commit to a repository or when an issue or pull request is created. You can also configure a workflow to run when an external event occurs using the repository dispatch webhook.

Artifact

构件是创建并测试代码时所创建的文件。 例如,构件可能包含二进制或包文件、测试结果、屏幕截图或日志文件。 Artifacts are associated with the workflow run where they were created and can be used by another job or deployed.

工作流程运行通知

If you enable email or web notifications for GitHub 操作, you'll receive a notification when any workflow runs that you've triggered have completed. The notification will include the workflow run's status (including successful, failed, neutral, and canceled runs). You can also choose to receive a notification only when a workflow run has failed.

You can also see the status of workflow runs on a repository's Actions tab. 更多信息请参阅“管理工作流程运行”。

发现 GitHub 社区中的操作

您可以使用 GitHub 上公共仓库中共享的开源操作自定义项目。 您可以找到并使用 GitHub in the github.com/actions 组织创建的操作。

将 GitHub 操作 从 HCL 迁移到 YAML 语法

GitHub no longer supports the HCL syntax in GitHub 操作.

If you participated in the limited public beta and created workflows with the HCL syntax, you already have access to the new limited public beta that uses YAML syntax.

You'll need to migrate any workflow files that use HCL syntax to use the new YAML syntax. 有关 YAML 语法以及 GitHub 操作 其他更改的详细信息,请参阅“GitHub 操作 的工作流程语法”和“关于 GitHub 操作”。

You'll also need to ensure you create a metadata file for any actions you've built. For more information, see "Metadata syntax for GitHub 操作" and "About actions."

使用限制

超过使用限制可能导致作业排队、无法运行或无法完成。限制可能会有变动。

此外,GitHub 操作 不可用于:

为防止违反这些限制和滥用 GitHub 操作,GitHub 得监控您对 GitHub 操作 的使用。 GitHub 操作 的误用可能导致作业终止,或者限制您使用 GitHub 操作 的能力。

申请加入 GitHub 操作 的有限公测版

GitHub 操作 目前为有限公测期,可能会有变动。 在公测期间,强烈建议不要将此功能用于高价值工作流程和内容。

如果您目前未参加有限公测,可到 GitHub 操作 页面申请加入有限公测

联系支持

If you need help with anything related to workflow configuration, such as syntax, virtual environments, or building actions, look for an existing topic or start a new one in the GitHub 社区论坛's GitHub 操作 board.

If you have feedback or feature requests for GitHub 操作, share those in the Feedback form for GitHub Actions.

Contact GitHub 支持GitHub 高级支持 for any of the following, whether your use or intended use falls into the usage limit categories:

如果您目前未参加有限公测,可到 GitHub 操作 页面申请加入有限公测

GitHub 支持 将只支持 YAML 语法,而不再支持 HCL 语法。

延伸阅读

问问别人

找不到要找的内容?

联系我们