我有一个 GitHub 工作流程,该工作流程在创建/同步/重新打开 PR 时启动
name: CI Deployment
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
stageA:
runs-on: ubuntu-latest
steps:
- name: Commit SHA
run: |
echo "pass"
stageB:
runs-on: ubuntu-latest
steps:
- name: Commit SHA
run: |
echo "fail"
exit 1
对于第一次运行,假设 stageB 失败。如何获得已通过的 stageA 的结果,以便我可以跳过该构建并仅运行 stageB。
P.S 我知道 GitHub 从 UI 中提供了
re-run failed job
的选项,但上面的用例只是一个例子,我的实际用例有点复杂,我需要之前运行结果的结果,以便我的 bash 脚本相应地运行。
在工作流程中使用 github cli 命令
gh run view PREVIOUS_WORKFLOW_RUN_NUMBER
获取上次运行的信息。对于您的示例,请使用选项 -j, --job <string> View a specific job ID from a run