Compare commits

...
Author SHA1 Message Date
kasun 282e1c5236 chore: add read-only CI wait to the Gitea helper
Polling CI with a shell loop triggered a permission prompt during /merge.
A dedicated WAIT command can be allowlisted on its own.
2026-11-22 19:27:04 +01:00
claude-bot Bot 339dcdd214 Merge pull request 'Enhancement: Deploy Proxmox infra automatically on merge' (#51) from enhancement/auto-deploy-proxmox-infra into main
Deploy Proxmox Infra / Pulumi Preview (push) Skipped
Deploy k8s Infra / Pulumi Preview (push) Skipped
Deploy k8s Apps / Pulumi Preview (push) Skipped
Deploy Monitoring / Pulumi Preview (push) Skipped
Deploy Proxmox Infra / Pulumi Deploy (push) Successful in 1m46s
Deploy k8s Infra / Pulumi Deploy (push) Successful in 48s
Deploy Monitoring / Pulumi Deploy (push) Successful in 44s
Deploy k8s Apps / Pulumi Deploy (push) Successful in 38s
2026-11-22 19:21:35 +01:00
3 changed files with 32 additions and 4 deletions

No files matched your search

+27
View File
@@ -15,6 +15,10 @@
# PATH path below /api/v1, e.g. /repos/kasun/homelab-infrastructure-as-code/pulls?state=open # PATH path below /api/v1, e.g. /repos/kasun/homelab-infrastructure-as-code/pulls?state=open
# BODY JSON string, or @file to send a file # BODY JSON string, or @file to send a file
# #
# Read-only CI wait: gitea.sh WAIT /repos/OWNER/REPO/commits/SHA/status
# Polls until checks finish. Exit 0: passed or no CI ran. 1: a check failed.
# 2: bad usage. 3: timed out after 15 minutes.
#
# Config (outside the repo, never committed): # Config (outside the repo, never committed):
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/url e.g. http://192.168.1.208:3000 # ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/url e.g. http://192.168.1.208:3000
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/token chmod 600 # ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/token chmod 600
@@ -28,6 +32,29 @@ method=${1:?usage: gitea.sh METHOD PATH [BODY]}
path=${2:?usage: gitea.sh METHOD PATH [BODY]} path=${2:?usage: gitea.sh METHOD PATH [BODY]}
body=${3:-} body=${3:-}
if [[ "$method" == "WAIT" ]]; then
[[ "$path" =~ ^/repos/[^/]+/[^/]+/commits/[0-9a-f]{40}/status$ ]] \
|| { echo "WAIT only accepts /repos/OWNER/REPO/commits/SHA/status" >&2; exit 2; }
for ((i = 1; i <= 45; i++)); do
status=$("$0" GET "$path") || status='{}'
total=$(jq '.statuses // [] | length' <<<"$status")
running=$(jq '[.statuses // [] | .[] | select(.status == "pending" or .status == "running")] | length' <<<"$status")
# Give checks time to register. Path-filtered workflows may never start any.
if (( total == 0 && i >= 7 )); then
echo "no CI ran"
exit 0
fi
if (( total > 0 && running == 0 && i >= 4 )); then
jq -r '.statuses[] | "\(.context): \(.status) \(.target_url)"' <<<"$status"
jq -e '[.statuses[].status] | any(. == "failure" or . == "error") | not' <<<"$status" >/dev/null || exit 1
exit 0
fi
sleep 20
done
echo "timed out waiting for CI" >&2
exit 3
fi
case "$method" in case "$method" in
GET | POST | PATCH | PUT | DELETE) ;; GET | POST | PATCH | PUT | DELETE) ;;
*) echo "unsupported method: $method" >&2; exit 2 ;; *) echo "unsupported method: $method" >&2; exit 2 ;;
+1
View File
@@ -62,6 +62,7 @@
"Bash(git add *)", "Bash(git add *)",
"Bash(git switch *)", "Bash(git switch *)",
"Bash(.claude/scripts/gitea.sh GET *)", "Bash(.claude/scripts/gitea.sh GET *)",
"Bash(.claude/scripts/gitea.sh WAIT *)",
"Bash(.claude/scripts/gitea.sh POST *)", "Bash(.claude/scripts/gitea.sh POST *)",
"Bash(git commit *)", "Bash(git commit *)",
"Bash(git push *)", "Bash(git push *)",
+4 -4
View File
@@ -71,11 +71,11 @@ Unless one exists, run `.claude/scripts/gitea.sh POST $REPO/pulls @<json file>`
## 6. Wait for CI ## 6. Wait for CI
Get the SHA with `git rev-parse HEAD`, then repeat `.claude/scripts/gitea.sh GET $REPO/commits/<sha>/status` until the state settles. Get the SHA with `git rev-parse HEAD`, then run `.claude/scripts/gitea.sh WAIT $REPO/commits/<sha>/status` as a background command. Do not write a polling loop, because that causes a permission prompt.
- `success`: continue. - Exit 0: checks passed, or it printed `no CI ran` because workflows are path-filtered. Continue.
- `failure` or `error`: stop, and report the failing check and its `target_url`. - Exit 1: stop, and report the failing check and its `target_url`.
- No statuses after about two minutes: workflows are path-filtered, so treat this as no CI for this PR and continue. - Exit 3: CI timed out. Stop and report it.
Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergeable` is true. Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergeable` is true.