nginx-php/scripts/drone-build.sh

41 lines
1016 B
Bash
Raw Permalink Normal View History

#!/bin/sh
# - docker build -t docker.pbiernat.dev/nginx-php:$CI_COMMIT_BRANCH .
# - docker images --format "{{.Repository}}:{{.Tag}}" | grep nginx-php:${CI_COMMIT_BRANCH}
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
branch=$CI_COMMIT_BRANCH
event=$CI_BUILD_EVENT
source_branch=$DRONE_SOURCE_BRANCH
2021-11-23 22:37:43 +01:00
step_name=$DRONE_STEP_NAME
if { contains "$branch" "feature_" && [ "$event" = push ]; } ; then
2021-11-23 22:45:05 +01:00
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:$branch .
return 0
fi
if { [ "$branch" = develop ] && [ "$event" = pull_request ]; } ; then
2021-11-23 22:45:05 +01:00
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:$source_branch .
return 0
fi
if { [ "$branch" = develop ] && [ "$event" = push ] && [ "$step_name" != build_feature ]; } ; then
2021-11-23 22:45:05 +01:00
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:dev .
return 0
fi