Skip to content

Use exact ref to get branch SHA1 #1589

Closed
@ErikJiang

Description

@ErikJiang

See the CI error log for:ensure valid branch and commit

Run INPUTS_SPRAY_REF=c13134b88117bc35d05b77c26e1cc5f80aea5624 2d0cc2b4ea1a5f578300536d711d10c626c390bb
  INPUTS_SPRAY_REF=c13134b88117bc35d05b77c[2](https://github.com/kubean-io/kubean/actions/runs/16213707874/job/45778451024#step:2:2)6e1cc5f80aea5624 2d0cc2b4ea1a5f578300536d711d10c626c390bb
  SPRAY_SHA=`git ls-remote https://github.com/kubernetes-sigs/kubespray.git ${INPUTS_SPRAY_REF} | awk '{ print $1}'`
  if [[ -z "${SPRAY_SHA}" ]];then
    if (( ${#INPUTS_SPRAY_REF} != 40 ));then
      echo "The sha length of the commit must be 40"
      exit 1
    fi
    SPRAY_SHA=${INPUTS_SPRAY_REF}
  fi
  echo image_tag_short_sha=$(echo ${SPRAY_SHA} | cut -c 1-7) >> $GITHUB_OUTPUT
  
  echo dockerfile_commit=$(curl -L \
    -H "Accept: application/vnd.github+json" \
    -H "Authorization: ***" \
    -H "X-GitHub-Api-Version: 2022-11-28" \
    https://api.github.com/repos/${GITHUB_REPOSITORY}/commits?path=build/images/kubespray/Dockerfile \
    |jq '.[0].sha' | tr -d '"') >> $GITHUB_OUTPUT
  shell: /usr/bin/bash -e {0}
/home/runner/work/_temp/fbb[3](https://github.com/kubean-io/kubean/actions/runs/16213707874/job/45778451024#step:2:3)e190-28f3-4286-ac81-ec6014391f78.sh: line 1: 2d0cc2b4ea1a5f578300536d711d10c626c390bb: command not found
Error: Process completed with exit code 127.

There are two sha1 values ​​obtained by INPUTS_SPRAY_REF, which is obviously abnormal. It should be caused by the lack of precise filtering when git gets branch sha1.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions