CICD-230 · Workflow execution state tracking
Encyclopedia · Advanced workflow orchestration · All snippets
Previous · CICD-229 · Next · CICD-231
1. Where it fits
- Placement CI run step or authorized lab terminal.
- Prerequisites authenticated GitHub CLI, approved target repositories, or Actions runner for YAML entries.
- Platforms github-actions, github-cli.
- Parameters
RUN_ID,TARGET_REPO.
2. Copy the snippet
bash
gh run view "${RUN_ID:?}" --repo "${TARGET_REPO:?}" --json status,conclusion,attempt,headSha,url > run-state.json
jq -e '.headSha and .url and .attempt' run-state.json3. How it works
The CLI targets a specific workflow run and reads or changes its run state. Check the run ID and attempt at the selected repository. The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate.
4. Verify the result
Store the snapshot as evidence and key polling by repository, run ID and attempt.
Validation syntax-validated (Bash parse). Status definitions.