From 93ac2cefaaa75f76d0fd90f64dd093868426dc21 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 27 Apr 2026 07:18:57 +0100 Subject: [PATCH] ci(docker): resolve short refs before checkout --- .../openclaw-live-and-e2e-checks-reusable.yml | 10 +++++++--- test/scripts/test-install-sh-docker.test.ts | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/openclaw-live-and-e2e-checks-reusable.yml b/.github/workflows/openclaw-live-and-e2e-checks-reusable.yml index 13ea6c50a1c..d308d0159c8 100644 --- a/.github/workflows/openclaw-live-and-e2e-checks-reusable.yml +++ b/.github/workflows/openclaw-live-and-e2e-checks-reusable.yml @@ -231,10 +231,9 @@ jobs: selected_sha: ${{ steps.validate.outputs.selected_sha }} trusted_reason: ${{ steps.validate.outputs.trusted_reason }} steps: - - name: Checkout selected ref + - name: Checkout workflow repository uses: actions/checkout@v6 with: - ref: ${{ inputs.ref }} fetch-depth: 0 - name: Validate selected ref @@ -244,12 +243,17 @@ jobs: shell: bash run: | set -euo pipefail - selected_sha="$(git rev-parse HEAD)" trusted_reason="" git fetch --no-tags origin '+refs/heads/*:refs/remotes/origin/*' git fetch --tags origin '+refs/tags/*:refs/tags/*' + # Resolve here instead of in actions/checkout so short SHAs work too. + if ! selected_sha="$(git rev-parse --verify "${INPUT_REF}^{commit}")"; then + echo "Ref '${INPUT_REF}' could not be resolved to a commit." >&2 + exit 1 + fi + if git merge-base --is-ancestor "$selected_sha" refs/remotes/origin/main; then trusted_reason="main-ancestor" elif git tag --points-at "$selected_sha" | grep -Eq '^v'; then diff --git a/test/scripts/test-install-sh-docker.test.ts b/test/scripts/test-install-sh-docker.test.ts index f7e0393c1bc..d99e0a4af2d 100644 --- a/test/scripts/test-install-sh-docker.test.ts +++ b/test/scripts/test-install-sh-docker.test.ts @@ -64,6 +64,7 @@ describe("test-install-sh-docker", () => { const workflow = readFileSync(LIVE_E2E_WORKFLOW_PATH, "utf8"); expect(workflow).toContain("git fetch --no-tags origin '+refs/heads/*:refs/remotes/origin/*'"); + expect(workflow).toContain('git rev-parse --verify "${INPUT_REF}^{commit}"'); expect(workflow).toContain("repository-branch-history"); expect(workflow).toContain("git tag --points-at \"$selected_sha\" | grep -Eq '^v'"); expect(workflow).toContain("reachable from an OpenClaw branch or release tag");