Skip to content

Commit 94b4117

Browse files
authored
Merge pull request #516 from geoadmin/bug-BGDIINF_SB-2353-ci-branch
BGDIINF_SB-2353: Fixing CI manual build
2 parents fbda0df + e6dd372 commit 94b4117

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

buildspec.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ phases:
2323
commands:
2424
- echo "Export of the image tag for build and push purposes"
2525
- echo "CODEBUILD_WEBHOOK_HEAD_REF=${CODEBUILD_WEBHOOK_HEAD_REF} CODEBUILD_WEBHOOK_BASE_REF=${CODEBUILD_WEBHOOK_BASE_REF}"
26-
- export GITHUB_BRANCH="${CODEBUILD_WEBHOOK_HEAD_REF#refs/heads/}"
26+
- |
27+
if [[ -n "${CODEBUILD_WEBHOOK_HEAD_REF}" ]]; then
28+
export GITHUB_BRANCH="${CODEBUILD_WEBHOOK_HEAD_REF#refs/heads/}"
29+
else
30+
# NOTE: For manual build trigger, CODEBUILD_WEBHOOK_HEAD_REF is not set therefore get
31+
# the branch name from git command. This is a bit hacky but did not find any other solution
32+
export GITHUB_BRANCH=$(git show-ref --heads | grep $(git --no-pager show --format=%H) | head -1 | awk '{gsub("refs/heads/", ""); print $2}')
33+
fi
2734
- export GITHUB_COMMIT=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
2835
- export GITHUB_TAG="$(git describe --tags 2>/dev/null)"
2936
- echo "GITHUB_BRANCH=${GITHUB_BRANCH} GITHUB_COMMIT=${GITHUB_COMMIT} GITHUB_TAG=${GITHUB_TAG} DOCKER_IMG_TAG=${DOCKER_IMG_TAG}"

0 commit comments

Comments
 (0)