feat: multi-server deployment topology and CI fan-out #5
@@ -285,8 +285,11 @@ runs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
body=$(printf '%s' "$response" | head -n -1)
|
# Split on the last newline: curl's -w appended the status code
|
||||||
code=$(printf '%s' "$response" | tail -n 1)
|
# there. Pure bash — `head -n -1` is GNU-only and fails on
|
||||||
|
# BSD/macOS, so the fan-out could not be tested locally.
|
||||||
|
code="${response##*$'\n'}"
|
||||||
|
body="${response%$'\n'*}"
|
||||||
echo "HTTP $code"
|
echo "HTTP $code"
|
||||||
printf '%s' "$body" | jq . || printf '%s\n' "$body"
|
printf '%s' "$body" | jq . || printf '%s\n' "$body"
|
||||||
|
|
||||||
@@ -306,11 +309,12 @@ runs:
|
|||||||
echo "all $attempted endpoint(s) updated"
|
echo "all $attempted endpoint(s) updated"
|
||||||
```
|
```
|
||||||
|
|
||||||
Three changes beyond the loop itself, each load-bearing:
|
Four changes beyond the loop itself, each load-bearing:
|
||||||
|
|
||||||
1. **All inputs moved into `env:`.** A multi-line `${{ inputs.endpoint }}` interpolated directly into the script body would break it syntactically. Moving the others too keeps one consistent style in a short script, and stops a value containing shell metacharacters from being executed.
|
1. **All inputs moved into `env:`.** A multi-line `${{ inputs.endpoint }}` interpolated directly into the script body would break it syntactically. Moving the others too keeps one consistent style in a short script, and stops a value containing shell metacharacters from being executed.
|
||||||
2. **`jq -nc` builds the payload** instead of hand-interpolating into a JSON string. A tag containing a quote previously produced malformed JSON and a confusing 400.
|
2. **`jq -nc` builds the payload** instead of hand-interpolating into a JSON string. A tag containing a quote previously produced malformed JSON and a confusing 400.
|
||||||
3. **`set -e` dropped**, `-uo pipefail` kept. This is the whole point of the task — see the comment in the script.
|
3. **`set -e` dropped**, `-uo pipefail` kept. This is the whole point of the task — see the comment in the script.
|
||||||
|
4. **`head -n -1` replaced by bash parameter expansion.** The existing action used `head -n -1`, which is GNU-only — it fails on BSD/macOS with `illegal line count`. That made the fan-out logic impossible to test on a developer machine, so the portability fix is what makes Steps 2-4 runnable at all. It also drops two subprocesses per endpoint.
|
||||||
|
|
||||||
- [ ] **Step 2: Verify the loop continues past a failure**
|
- [ ] **Step 2: Verify the loop continues past a failure**
|
||||||
|
|
||||||
@@ -364,8 +368,8 @@ while IFS= read -r endpoint; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
body=$(printf '%s' "$response" | head -n -1)
|
code="${response##*$'\n'}"
|
||||||
code=$(printf '%s' "$response" | tail -n 1)
|
body="${response%$'\n'*}"
|
||||||
echo "HTTP $code"
|
echo "HTTP $code"
|
||||||
printf '%s' "$body" | jq . || printf '%s\n' "$body"
|
printf '%s' "$body" | jq . || printf '%s\n' "$body"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user