-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
35 lines (28 loc) · 940 Bytes
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
stages:
- build
build image:
stage: build
image: docker:git
services:
- docker:dind
script:
- build_terraform
.auto_devops: &auto_devops |
[[ "$TRACE" ]] && set -x
export CI_APPLICATION_TAG=$CI_COMMIT_SHA
[[ "$CI_APPLICATION_TAG" = "master" ]] && export CI_APPLICATION_TAG="latest"
[[ "$CI_COMMIT_TAG" ]] && export CI_APPLICATION_TAG=$CI_COMMIT_TAG
build_terraform() {
export CI_APPLICATION_REPOSITORY=$CI_REGISTRY_IMAGE/hetzner
docker build --pull --rm -t "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" hetzner/
if [[ -n "$CI_REGISTRY_USER" ]]; then
echo "Logging to GitLab Container Registry with CI credentials..."
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
echo ""
fi
echo "Pushing to GitLab Container Registry..."
docker push "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG"
echo ""
}
before_script:
- *auto_devops