ceph-csi/deploy/checkout-repo.sh
Niels de Vos b1d7c83c16 ci: checkout FETCH_HEAD instead of GIT_REF
GIT_REF can point to a ref that it not part of a branch and can not
easily be checked out (like a GitHub PR). Checking out FETCH_HEAD after
fetching the GIT_REF works.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2020-09-22 11:59:31 +02:00

18 lines
335 B
Bash
Executable File

#!/bin/sh
fail() {
echo "${@}" > /dev/stderr
exit 1
}
[ -n "${GIT_REPO}" ] || fail 'GIT_REPO environment variable not set'
[ -n "${GIT_REF}" ] || fail 'GIT_REF environment variable not set'
# exit in case a command fails
set -e
git init .
git remote add origin "${GIT_REPO}"
git fetch origin "${GIT_REF}"
git checkout FETCH_HEAD