仅在 GitHub 操作矩阵中重新 运行 失败的作业
Only re-run the failed job in a GitHub Actions matrix
如何重新运行 GitHub 操作矩阵中的失败作业?
我只想 运行 失败的作业,而不是全部。我的 CI 矩阵需要很多时间才能 运行,我不想因为其中一个失败而浪费精力重新 运行 整个矩阵。
所以这个按钮不是我的解决方案:
Re-run具体工作尚未实施,but it is on the roadmap。
但是,读取 this ISSUE about the subject, there is a workaround from this 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 }}
GitHub终于让这件事成为可能了。现在有一个“Re-run 个失败的作业”按钮:
如何重新运行 GitHub 操作矩阵中的失败作业?
我只想 运行 失败的作业,而不是全部。我的 CI 矩阵需要很多时间才能 运行,我不想因为其中一个失败而浪费精力重新 运行 整个矩阵。
所以这个按钮不是我的解决方案:
Re-run具体工作尚未实施,but it is on the roadmap。
但是,读取 this ISSUE about the subject, there is a workaround from this 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 }}
GitHub终于让这件事成为可能了。现在有一个“Re-run 个失败的作业”按钮: