Skip to main content
我们经常发布文档更新,此页面的翻译可能仍在进行中。 有关最新信息,请访问英语文档
GitHub AE 目前处于受限版。

重新运行工作流程和作业

可以在工作流运行初始运行后最长 30 天内重新运行工作流运行、工作流运行中所有失败的作业或工作流运行中的特定作业。

谁可以使用此功能

People with write permissions to a repository can re-run workflows in the repository.

About re-running workflows and jobs

Re-running a workflow or jobs in a workflow uses the same GITHUB_SHA (commit SHA) and GITHUB_REF (Git ref) of the original event that triggered the workflow run. You can re-run a workflow or jobs in a workflow for up to 30 days after the initial run. When you re-run a workflow or jobs in a workflow, you can enable debug logging for the re-run. This will enable runner diagnostic logging and step debug logging for the re-run. For more information about debug logging, see "Enabling debug logging."

Re-running all the jobs in a workflow

  1. On your enterprise, navigate to the main page of the repository.

  2. Under your repository name, click Actions. Actions tab in the main repository navigation

  3. In the left sidebar, click the workflow you want to see. Workflow list in left sidebar

  4. From the list of workflow runs, click the name of the run to see the workflow run summary.

    Name of workflow run

  5. In the upper-right corner of the workflow, use the Re-run jobs drop-down menu, and select Re-run all jobs.

    If no jobs failed, you will not see the Re-run jobs drop-down menu. Instead, click Re-run all jobs.

    Rerun checks drop-down menu

  6. In the upper-right corner of the workflow, use the Re-run jobs drop-down menu, and select Re-run all jobs.

    Re-run checks drop-down menu

  7. Optionally, to enable runner diagnostic logging and step debug logging for the re-run, select Enable debug logging. Enable debug logging

To learn more about GitHub CLI, see "About GitHub CLI."

To re-run a failed workflow run, use the run rerun subcommand. Replace run-id with the ID of the failed run that you want to re-run. If you don't specify a run-id, GitHub CLI returns an interactive menu for you to choose a recent failed run.

gh run rerun RUN_ID

To enable enable runner diagnostic logging and step debug logging for the re-run, use the --debug flag.

gh run rerun RUN_ID --debug

To view the progress of the workflow run, use the run watch subcommand and select the run from the interactive list.

gh run watch

Re-running failed jobs in a workflow

If any jobs in a workflow run failed, you can re-run just the jobs that failed. When you re-run failed jobs in a workflow, a new workflow run will start for all failed jobs and their dependents. Any outputs for any successful jobs in the previous workflow run will be used for the re-run. Any artifacts that were created in the initial run will be available in the re-run. Any environment protection rules that passed in the previous run will automatically pass in the re-run.

  1. On your enterprise, navigate to the main page of the repository.

  2. Under your repository name, click Actions. Actions tab in the main repository navigation

  3. In the left sidebar, click the workflow you want to see. Workflow list in left sidebar

  4. From the list of workflow runs, click the name of the run to see the workflow run summary.

    Name of workflow run

  5. In the upper-right corner of the workflow, use the Re-run jobs drop-down menu, and select Re-run failed jobs.

    Rerun checks drop-down menu

  6. Optionally, to enable runner diagnostic logging and step debug logging for the re-run, select Enable debug logging. Enable debug logging

To re-run failed jobs in a workflow run, use the run rerun subcommand with the --failed flag. Replace run-id with the ID of the run for which you want to re-run failed jobs. If you don't specify a run-id, GitHub CLI returns an interactive menu for you to choose a recent failed run.

gh run rerun RUN_ID --failed

To enable enable runner diagnostic logging and step debug logging for the re-run, use the --debug flag.

gh run rerun RUN_ID --failed --debug

Re-running a specific job in a workflow

When you re-run a specific job in a workflow, a new workflow run will start for the job and any dependents. Any outputs for any other jobs in the previous workflow run will be used for the re-run. Any artifacts that were created in the initial run will be available in the re-run. Any environment protection rules that passed in the previous run will automatically pass in the re-run.

  1. On your enterprise, navigate to the main page of the repository.

  2. Under your repository name, click Actions. Actions tab in the main repository navigation

  3. In the left sidebar, click the workflow you want to see. Workflow list in left sidebar

  4. From the list of workflow runs, click the name of the run to see the workflow run summary.

    Name of workflow run

  5. Next to the job that you want to re-run, click . Re-run selected job

    Alternatively, click on a job to view the log. In the log, click . Re-run selected job

  6. Optionally, to enable runner diagnostic logging and step debug logging for the re-run, select Enable debug logging. Enable debug logging

To re-run a specific job in a workflow run, use the run rerun subcommand with the --job flag. Replace job-id with the ID of the job that you want to re-run.

gh run rerun --job JOB_ID

To enable enable runner diagnostic logging and step debug logging for the re-run, use the --debug flag.

gh run rerun --job JOB_ID --debug

Re-running workflows and jobs with reusable workflows

Reusable workflows from public repositories can be referenced using a SHA, a release tag, or a branch name. For more information, see "Reusing workflows."

When you re-run a workflow that uses a reusable workflow and the reference is not a SHA, there are some behaviors to be aware of:

  • Re-running all jobs in a workflow will use the reusable workflow from the specified reference. For more information about re-running all jobs in a workflow, see "Re-running workflows and jobs."
  • Re-running failed jobs or a specific job in a workflow will use the reusable workflow from the same commit SHA of the first attempt. For more information about re-running failed jobs in a workflow, see "Re-running workflows and jobs." For more information about re-running a specific job in a workflow, see "Re-running workflows and jobs."

Reviewing previous workflow runs

You can view the results from your previous attempts at running a workflow. You can also view previous workflow runs using the API. For more information, see "Actions."

  1. On your enterprise, navigate to the main page of the repository.

  2. Under your repository name, click Actions. Actions tab in the main repository navigation

  3. In the left sidebar, click the workflow you want to see. Workflow list in left sidebar

  4. From the list of workflow runs, click the name of the run to see the workflow run summary.

    Name of workflow run

  5. Any previous run attempts are shown in the Latest drop-down menu. Previous run attempts

  6. Click an entry to view its results.