注: GitHub 托管的运行器目前在 GitHub Enterprise Server 上不受支持。 您可以在 GitHub 公共路线图 上查看有关未来支持计划的更多信息。
概览
A workflow run is made up of one or more jobs, which run in parallel by default. 要按顺序运行作业,您可以使用 <job_id>needs 关键词在其他作业上定义依赖项。
每个作业在 runs-on 指定的运行器环境中运行。
在工作流程的使用限制之内可运行� 限数量的作业。 For more information, see "Usage limits and billing" for GitHub-hosted runners and "About self-hosted runners" for self-hosted runner usage limits.
If you need to find the unique identifier of a job running in a workflow run, you can use the GitHub Enterprise Server API. 更多信息请参阅“工作流程作业”。
设置作业的 ID
Use jobs.<job_id> to give your job a unique identifier. 键值 job_id 是一个字符串,其值是作业配置数据的� 像。 必须将 <job_id> 替换为 jobs 对象唯一的字符串。 <job_id> 必须以字母或 _ 开头,并且只能包含字母数字字符、- 或 _。
Example: Creating jobs
In this example, two jobs have been created, and their job_id values are my_first_job and my_second_job.
jobs: my_first_job: name: My first job my_second_job: name: My second job 设置作业的名称
Use jobs.<job_id>.name to set a name for the job, which is displayed in the GitHub UI.
定义必备作业
Use jobs.<job_id>.needs to identify any jobs that must complete successfully before this job will run. 它可以是一个字符串,也可以是字符串数组。 如果某个作业失败,则所有需要它的作业都会被跳过,除非这些作业使用让该作业继续的条件表达式。 If a run contains a series of jobs that need each other, a failure applies to all jobs in the dependency chain from the point of failure onwards.
Example: Requiring successful dependent jobs
jobs: job1: job2: needs: job1 job3: needs: [job1, job2] 在此示例中,job1 必须在 job2 开始之前成功完成,而 job3 要等待 job1 和 job2 完成。
此示例中的作业按顺序运行:
job1job2job3
Example: Not requiring successful dependent jobs
jobs: job1: job2: needs: job1 job3: if: ${{ always() }} needs: [job1, job2] 在此示例中,job3 使用 always() 条件表达式,� 此它始终在 job1 和 job2 完成后运行,不管它们是否成功。 更多信息请参阅“表达式”。