mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 04:43:57 +00:00
fix(ci): stabilize manual dispatch checkout
This commit is contained in:
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@@ -126,6 +126,7 @@ jobs:
|
||||
env:
|
||||
CHECKOUT_REPO: ${{ github.repository }}
|
||||
CHECKOUT_REF: ${{ inputs.target_ref || github.sha }}
|
||||
CHECKOUT_EVENT_REF: ${{ github.ref }}
|
||||
CHECKOUT_FALLBACK_REF: ${{ github.sha }}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
run: |
|
||||
@@ -152,12 +153,29 @@ jobs:
|
||||
sleep 5
|
||||
done
|
||||
}
|
||||
if fetch_checkout_ref "$CHECKOUT_REF"; then
|
||||
|
||||
# Manual release-gate runs commonly validate the workflow ref's exact SHA.
|
||||
# Fetch the branch/tag ref first so GitHub does not have to negotiate an
|
||||
# arbitrary SHA fetch, then verify the resolved commit stayed pinned.
|
||||
checkout_ref="$CHECKOUT_REF"
|
||||
requested_sha=""
|
||||
if [[ "$CHECKOUT_REF" =~ ^[0-9a-f]{40}$ ]]; then
|
||||
requested_sha="$CHECKOUT_REF"
|
||||
if [[
|
||||
"$GITHUB_EVENT_NAME" == "workflow_dispatch" &&
|
||||
"$CHECKOUT_REF" == "$CHECKOUT_FALLBACK_REF" &&
|
||||
-n "$CHECKOUT_EVENT_REF"
|
||||
]]; then
|
||||
checkout_ref="$CHECKOUT_EVENT_REF"
|
||||
fi
|
||||
fi
|
||||
|
||||
if fetch_checkout_ref "$checkout_ref"; then
|
||||
:
|
||||
else
|
||||
fetch_status="$?"
|
||||
if [ "$fetch_status" = "124" ] || [ "$fetch_status" = "137" ]; then
|
||||
echo "::error::checkout fetch for '$CHECKOUT_REF' timed out"
|
||||
echo "::error::checkout fetch for '$checkout_ref' timed out"
|
||||
exit "$fetch_status"
|
||||
fi
|
||||
if [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ] || [ "$CHECKOUT_REF" = "$CHECKOUT_FALLBACK_REF" ]; then
|
||||
@@ -166,6 +184,15 @@ jobs:
|
||||
echo "::warning::workflow_dispatch target_ref '$CHECKOUT_REF' is unavailable; falling back to head SHA '$CHECKOUT_FALLBACK_REF'"
|
||||
fetch_checkout_ref "$CHECKOUT_FALLBACK_REF"
|
||||
fi
|
||||
|
||||
if [ -n "$requested_sha" ]; then
|
||||
resolved_sha="$(git -C "$GITHUB_WORKSPACE" rev-parse refs/remotes/origin/checkout)"
|
||||
if [ "$resolved_sha" != "$requested_sha" ]; then
|
||||
echo "::error::checkout ref '$checkout_ref' resolved to '$resolved_sha'," \
|
||||
"expected '$requested_sha'" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
|
||||
|
||||
- name: Resolve checkout SHA
|
||||
|
||||
Reference in New Issue
Block a user