Skip to content

CICD-226 · Workflow cancellation through API ​

Encyclopedia · Advanced workflow orchestration · All snippets

Previous · CICD-225 · Next · CICD-227

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 cancel "${RUN_ID:?}" --repo "${TARGET_REPO:?}"
gh run view "$RUN_ID" --repo "$TARGET_REPO" --json status,conclusion

3. 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.

4. Verify the result ​

Use Actions write in an authorized repository. Poll until conclusion becomes cancelled.

Validation syntax-validated (Bash parse). Status definitions.