Commit 6d555f2
authored
Replace curl+bash API layer with zad-cli (#41)
* refactor: replace curl+bash API layer with zad-cli
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.
* fix: address PR review - error detail, temp files, validation, install
- 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)
* refactor: unify shared helpers, fix all review issues
- 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)
* fix: suppress shellcheck SC2034 for variables used by callers
* fix: pin zad-cli to version tag and use uv for installation
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).
* fix: restore input validation and harden CLI error handling
- 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.
* fix: add setup-uv, fix validation exits, harden CLI install
- 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
* fix: correct uv tool bin path and not_found cleanup counting
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.1 parent 68688a1 commit 6d555f2
5 files changed
Lines changed: 303 additions & 400 deletions
File tree
- cleanup
- deploy
- scheduled-cleanup
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
10 | 29 | | |
11 | 30 | | |
12 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
138 | 150 | | |
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
142 | 154 | | |
143 | 155 | | |
144 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
145 | 162 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 163 | + | |
151 | 164 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 165 | | |
184 | 166 | | |
185 | 167 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
189 | 175 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 176 | + | |
193 | 177 | | |
194 | | - | |
| 178 | + | |
195 | 179 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
221 | 184 | | |
| 185 | + | |
222 | 186 | | |
223 | 187 | | |
224 | 188 | | |
| |||
0 commit comments