Replace curl+bash API layer with zad-cli#41
Merged
Conversation
Collaborator
|
I like this. The CLI makes 'local' commands easier; and keeping the logic in one place (now the CLI) means the action can just be 'a wrapper'. So, LGTM! Go! :) |
uittenbroekrobbert
approved these changes
Mar 24, 2026
Replace all ZAD API interactions (curl_with_retry, poll_task, build_poll_url, payload building) with zad-cli calls. The CLI handles retry logic, task polling, and error handling identically. - deploy: ~200 lines of curl/jq/polling replaced by single CLI call - cleanup: ~80 lines of curl/polling replaced by single CLI call - scheduled-cleanup: same ZAD delete logic replaced by CLI call - Remove scripts/zad-common.sh (124 lines, now redundant) GitHub-specific logic (bot detection, PR comments, QR codes, environment/deployment/container cleanup) unchanged. Net reduction: ~310 lines of duplicated bash.
- Structured error reporting: parse CLI JSON status_code for specific ::error:: annotations (401/403/404/5xx), matching original messages - Add scripts/zad-error.sh helper for deploy action error reporting - Remove zad_stderr.txt temp file usage: CLI JSON errors go to stdout in --output json mode, so stderr redirect was reading the wrong stream - Restore domain_format subdomain-requires-subdomain validation in deploy action (not covered by CLI validation) - Use uv for installation (faster, consistent with project tooling) - Install from main without version pin (both repos under same team)
- Consolidate zad-error.sh into zad-common.sh with install_zad_cli, report_zad_error, and zad_delete_deployment functions - All three actions now use the same shared functions (DRY) - cleanup and scheduled-cleanup use zad_delete_deployment instead of duplicated inline error parsing - Replace curl|sh uv install with pip install (available on all GitHub runners, no external script execution) - Remove zad-error.sh (merged into zad-common.sh)
Install from a specific version tag (v0.1.1) instead of unpinned main to prevent breaking changes from affecting all workflows. Switch from pip to uv (faster, consistent with project tooling).
- Restore input validation (project-id, deployment-name, component names, numeric inputs, domain inputs) before logging to prevent injection. Extracted validate_input and validate_integer helpers to zad-common.sh for reuse across all three actions. - Handle non-JSON CLI output in report_zad_error (crashes, missing binary, Python tracebacks no longer produce misleading messages). - Check install_zad_cli exit code and verify zad is in PATH. - Reset DELETE_RESULT/DELETE_REASON at start of zad_delete_deployment to prevent stale values when called in a loop. - Use ::warning:: (not ::error::) for cleanup delete failures to match the original best-effort behavior.
- Add astral-sh/setup-uv@v6 step before zad-cli install (uv is not pre-installed on GitHub runners) - Add $HOME/.local/bin to GITHUB_PATH so zad is available across steps - Change validate_input/validate_integer from return 1 to exit 1 (without set -e, return 1 was silently ignored) - Add missing validate_input for project-id in scheduled-cleanup - Improve error message for CLI failures with no HTTP status code - Update CHANGELOG.md with full PR scope
Use `uv tool bin` instead of broken `uv tool dir/../bin` fallback, and make PATH export consistent with whichever branch fires. Count not_found deployments as successfully cleaned in scheduled-cleanup since a missing deployment is already clean.
477c821 to
a3b0b5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zad-cliinstead of raw curl+bashscripts/zad-common.sh(124 lines) - retry logic, task polling, URL building now handled by the CLIWhat changed per action
zad deployment createcallzad deployment delete --ignore-not-foundcallzad deployment deletecallHow it works
Each action gets a new "Install zad-cli" step (
pipx install) before the ZAD API step. The CLI picks up configuration via env vars:ZAD_API_KEY,ZAD_API_URL,ZAD_PROJECT_ID(existing)ZAD_TASK_TIMEOUT,ZAD_TASK_POLL_INTERVAL(new in CLI)ZAD_MAX_RETRIES,ZAD_RETRY_DELAY(new in CLI)Dependencies
Requires RijksICTGilde/zad-cli with the env var support for retry/timeout settings (already merged to main).
Test plan
🤖 Generated with Claude Code