仅在 GitHub Actions 矩阵中重新运行失败的作业

发布于 2025-01-10 22:41:29 字数 274 浏览 0 评论 0 原文

如何仅重新运行 GitHub Actions 矩阵中失败的作业?

我只想运行失败的作业,而不是全部。我的 CI 矩阵需要很多时间来运行,我不想浪费精力重新运行整个矩阵,因为其中一个矩阵失败了。

所以这个按钮不是我的解决方案:

不重新运行所有作业

How can I re-run only a failed job in a GitHub Actions matrix?

I only want to run the failed jobs and not all of them. My CI matrix takes a lot of time to run, and I don't want to waste energy re-running the whole matrix because one of them failed.

So this button is not my solution:

No Re-run all jobs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

金兰素衣 2025-01-17 22:41:29

重新运行特定作业尚未实现,但已在路线图上

但是,阅读有关该主题的此问题,可以找到 这个post,它将上次运行状态存储在缓存中,然后根据该状态跳过作业。

他们如何使用它:

    - name: Set default run status
      run: echo "::set-output name=last_run_status::default" > last_run_status

    - name: Restore last run status
      id: last_run
      uses: actions/cache@v2
      with:
        path: |
          last_run_status
        key: ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.webpack }}-${{ steps.date.outputs.date }}
        restore-keys: |
          ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.webpack }}-

    - name: Set last run status
      id: last_run_status
      run: cat last_run_status

    - name: Checkout ref
      uses: actions/checkout@v2
      with:
        ref: ${{ github.event.workflow_dispatch.ref }}

    - name: Use Node.js ${{ matrix.node-version }}
      if: steps.last_run_status.outputs.last_run_status != 'success'
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

此处是原始工作流程文件

Re-run a specific job has not been implemented yet, but it is on the roadmap.

However, reading this ISSUE about the subject, there is a workaround from this post, which stores the last run status in cache and then skips jobs based on that status.

How they used it:

    - name: Set default run status
      run: echo "::set-output name=last_run_status::default" > last_run_status

    - name: Restore last run status
      id: last_run
      uses: actions/cache@v2
      with:
        path: |
          last_run_status
        key: ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.webpack }}-${{ steps.date.outputs.date }}
        restore-keys: |
          ${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.webpack }}-

    - name: Set last run status
      id: last_run_status
      run: cat last_run_status

    - name: Checkout ref
      uses: actions/checkout@v2
      with:
        ref: ${{ github.event.workflow_dispatch.ref }}

    - name: Use Node.js ${{ matrix.node-version }}
      if: steps.last_run_status.outputs.last_run_status != 'success'
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

Here is the original workflow file.

陌生 2025-01-17 22:41:29

GitHub 终于让这件事成为可能。现在有一个“重新运行失败的作业”按钮:

在此处输入图像描述

GitHub finally made it possible to do this. There is now a "Re-run failed jobs" button:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文