Refactor GitLab CI/CD pipelines
This commit is contained in:
16
ci-templates.yml
Normal file
16
ci-templates.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
.docker_build_template:
|
||||
image: docker:20.10@sha256:2967f0819c84dd589ed0a023b9d25dcfe7a3c123d5bf784ffbb77edf55335f0c
|
||||
before_script:
|
||||
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
|
||||
script:
|
||||
- cd $DOCKER_CONTEXT
|
||||
- |
|
||||
echo "Building Docker image for $DOCKER_IMAGE with tag $TAG"
|
||||
docker build $DOCKER_BUILD_ARGS -t $DOCKER_IMAGE:$TAG -f $DOCKERFILE .
|
||||
- |
|
||||
if [[ "$RAW_TAG" == "dev" || "$RAW_TAG" == "production" ]]; then
|
||||
echo "Pushing Docker image $DOCKER_IMAGE:$TAG"
|
||||
docker push $DOCKER_IMAGE:$TAG
|
||||
else
|
||||
echo "Skipping Docker push for non-dev or production branch: $RAW_TAG"
|
||||
fi
|
||||
Reference in New Issue
Block a user