Skip to content

Commit 3bc4eff

Browse files
committed
fix: bound branch lookup with timeouts and explicit curl exit check
Transient network issues could stall the release workflow indefinitely, and a curl failure was only distinguishable from an HTTP response via the status output. Add connect/overall timeouts with a small retry policy, check curl's exit code explicitly, and cap the job with timeout-minutes. Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent daff6be commit 3bc4eff

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212

1313
prepare-release:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 10
1516
env:
1617
tmp_version_branch: ''
1718
outputs:
@@ -48,14 +49,22 @@ jobs:
4849
# the 999-SNAPSHOT sentinel version.
4950
echo "Release tag major.minor: $RELEASE_MAJOR_MINOR"
5051
51-
# Only 404 means "no such branch". Any other status is a lookup failure
52+
# Only 404 means "no such branch". Any other outcome is a lookup failure
5253
# and must abort: silently falling back to main would release the wrong
53-
# stream.
54+
# stream. Timeouts are bounded so a network stall fails fast.
55+
CURL_EXIT=0
5456
HTTP_STATUS=$(curl -sS -o /dev/null -w '%{http_code}' \
57+
--connect-timeout 10 --max-time 30 \
58+
--retry 3 --retry-delay 2 --retry-all-errors \
5559
-H "Authorization: Bearer ${GH_TOKEN}" \
5660
-H "Accept: application/vnd.github+json" \
5761
-H "X-GitHub-Api-Version: 2022-11-28" \
58-
"${{ github.api_url }}/repos/${{ github.repository }}/branches/${MAINTENANCE_BRANCH}")
62+
"${{ github.api_url }}/repos/${{ github.repository }}/branches/${MAINTENANCE_BRANCH}") || CURL_EXIT=$?
63+
64+
if [ "$CURL_EXIT" -ne 0 ]; then
65+
echo "Branch lookup for ${MAINTENANCE_BRANCH} failed (curl exit ${CURL_EXIT})"
66+
exit 1
67+
fi
5968
6069
case "$HTTP_STATUS" in
6170
200)

0 commit comments

Comments
 (0)