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

关于 GitHub 操作

GitHub 操作 可让您直接在 GitHub 仓库中创建自定义软件开发生命周期工作流程。

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

本文内容

](#about-github-actions)

关于

GitHub 操作 GitHub 操作 gives you the flexibility to build an automated software development lifecycle workflow. You can write individual tasks, called actions, and combine them to create a custom workflow. 工作流程是您可以在仓库中创建的自定义自动化流程,用于在 GitHub 上构建、测试、封装、发行或部署任何代码项目。

GitHub 操作 允许直接在仓库中构建端到端持续集成和持续部署功能。 GitHub 操作 支持 GitHub 的内置持续集成 (CI) 服务。 更多信息请参阅“关于持续集成”。

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

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

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

GitHub 操作 的核心概念

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

Workflow

A configurable automated process that you can set up in your repository to build, test, package, release, or deploy any project on GitHub. Workflows are made up of one or more jobs and can be scheduled or activated by an event.

Workflow run

An instance of your workflow that runs when the pre-configured event occurs. You can see the jobs, actions, logs, and statuses for each workflow run.

Workflow file

The YAML file that defines your workflow configuration with at least one job. This file lives in the root of your GitHub repository in the .github/workflows directory.

Job

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.

Step

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.

Action

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.

Virtual environment

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 the files created when you build and test your code. For example, artifacts might include binary or package files, test results, screenshots, or log files. 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. For more information, see "Managing a workflow run."

发现 GitHub 社区中的操作

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

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

Support for the HCL syntax in GitHub 操作 will be deprecated on September 30, 2019.

If you participated in the limited public beta and created workflows with the HCL syntax GitHub 操作, you will need to upgrade to the new limited public beta that uses YAML syntax. When your repository is eligible to upgrade, you'll see an invitation in your repository. You must accept the invitation before you can use the new limited public beta.

Any workflows that you created with the HCL syntax will need to be updated to the new YAML syntax. To automatically convert your workflows and actions, see "Migrating GitHub 操作 from HCL syntax to YAML syntax."

使用限制

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

此外,GitHub 操作 不可用于:

为防止违反这些限制和滥用 GitHub 操作,GitHub 得监控您对 GitHub 操作 的使用。 GitHub 操作 的误用可能导致作业终止,或者限制您使用 GitHub 操作 的能力。 如果对您的使用或预期使用是否属于这些类别有疑问,或者您认为您的帐户被错误限制,请联系 GitHub 支持GitHub 高级支持

联系支持

If you're a participant in the limited public beta, please contact GitHub 支持 using our contact form and the subject line "GitHub 操作."

If you're not currently participating in the limited public beta, you can request to join the limited public beta on the GitHub 操作 page.

GitHub 支持 will only provide support for the YAML syntax and no longer provides support for the HCL syntax.

延伸阅读

问问别人

找不到要找的内容?

联系我们