Skip to content

Commit

Permalink
Tag PR images differently to prevent accidental prod deploy (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsquizz authored Nov 9, 2021
1 parent 64e50e1 commit 13a5d6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cicd/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export WORKSPACE=${WORKSPACE:-$APP_ROOT} # if running in jenkins, use the build
export BONFIRE_ROOT=${WORKSPACE}/bonfire
export CICD_ROOT=${BONFIRE_ROOT}/cicd
export IMAGE_TAG=$(git rev-parse --short=7 HEAD)

# if this is a PR, use a different tag, since PR tags expire
if [ ! -z "$ghprbPullId" ]; then
export IMAGE_TAG="pr-${ghprbPullId}-${IMAGE_TAG}"
fi

if [ ! -z "$gitlabMergeRequestIid" ]; then
export IMAGE_TAG="pr-${gitlabMergeRequestIid}-${IMAGE_TAG}"
fi


export GIT_COMMIT=$(git rev-parse HEAD)
export ARTIFACTS_DIR="$WORKSPACE/artifacts"

Expand Down
5 changes: 4 additions & 1 deletion cicd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ function build {
exit 1
fi

echo "LABEL quay.expires-after=3d" >> $APP_ROOT/$DOCKERFILE # tag expires in 3 days
# if this is a PR, set the tag to expire in 3 days
if [ ! -z "$ghprbPullId" ] || [ ! -z "$gitlabMergeRequestIid" ]; then
echo "LABEL quay.expires-after=3d" >> $APP_ROOT/$DOCKERFILE
fi

if test -f /etc/redhat-release && grep -q -i "release 7" /etc/redhat-release; then
# on RHEL7, use docker
Expand Down

0 comments on commit 13a5d6b

Please sign in to comment.