Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds git sha scope for variable injection #211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions legacy/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ if [[ "$BUILD_TYPE" == "pullrequest" || "$BUILD_TYPE" == "branch" ]]; then
set -x

if [ "$BUILD_TYPE" == "branch" ]; then
BUILD_ARGS+=(--build-arg LAGOON_GIT_SHA="${LAGOON_GIT_SHA}")
BUILD_ARGS+=(--build-arg LAGOON_GIT_SHA="${LAGOON_BUILD_GIT_SHA}")
BUILD_ARGS+=(--build-arg LAGOON_GIT_BRANCH="${BRANCH}")
fi

if [ "$BUILD_TYPE" == "pullrequest" ]; then
BUILD_ARGS+=(--build-arg LAGOON_GIT_SHA="${LAGOON_GIT_SHA}")
BUILD_ARGS+=(--build-arg LAGOON_GIT_SHA="${LAGOON_BUILD_GIT_SHA}")
BUILD_ARGS+=(--build-arg LAGOON_PR_HEAD_BRANCH="${PR_HEAD_BRANCH}")
BUILD_ARGS+=(--build-arg LAGOON_PR_HEAD_SHA="${PR_HEAD_SHA}")
BUILD_ARGS+=(--build-arg LAGOON_PR_BASE_BRANCH="${PR_BASE_BRANCH}")
Expand Down
26 changes: 20 additions & 6 deletions legacy/build-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,27 @@ if [ ! -f .lagoon.yml ]; then
echo "no .lagoon.yml file found"; exit 1;
fi

# Here we grab the git sha to populate build and runtime environment variables
GIT_SHA=`git rev-parse HEAD`
INJECT_GIT_SHA=$(cat .lagoon.yml | shyaml get-value environment_variables.git_sha false)
if [ "$INJECT_GIT_SHA" == "true" ]
then
LAGOON_GIT_SHA=`git rev-parse HEAD`
else
LAGOON_GIT_SHA="0000000000000000000000000000000000000000"
fi
case "$INJECT_GIT_SHA" in
true|both)
LAGOON_GIT_SHA=$GIT_SHA
LAGOON_BUILD_GIT_SHA=$GIT_SHA
;;
build)
LAGOON_BUILD_GIT_SHA=$GIT_SHA
LAGOON_GIT_SHA="0000000000000000000000000000000000000000"
;;
runtime)
LAGOON_BUILD_GIT_SHA="0000000000000000000000000000000000000000"
LAGOON_GIT_SHA=$GIT_SHA
;;
*)
LAGOON_GIT_SHA="0000000000000000000000000000000000000000"
LAGOON_BUILD_GIT_SHA=$LAGOON_GIT_SHA
;;
esac
Comment on lines +50 to +67
Copy link
Member

@shreddedbacon shreddedbacon Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concerns with this are that the environment_variables.git_sha field goes from being a boolean, to a string. I think it is ok though.

Edit: And this field isn't in the go rewrite yet either, so I'm more comfortable with it changing now before it gets merged into the newer code base.


echo -e "##############################################\nBEGIN Kubernetes and Container Registry Setup\n##############################################"
sleep 0.5s
Expand Down