-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
43 lines (38 loc) · 1.37 KB
/
.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
36
37
38
39
40
41
42
43
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_HEROKU_IMAGE: registry.heroku.com/$HEROKU_APP_NAME/app
stages:
- build
- release
before_script:
- "docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY"
docker-build:
stage: build
script:
- docker build --pull -f Dockerfile --iidfile imageid.txt -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_HEROKU_IMAGE
- docker login -u _ -p $HEROKU_TOKEN registry.heroku.com
- docker push $CONTAINER_HEROKU_IMAGE
- echo "push completed"
- apk add --no-cache curl
- echo "Docker Image ID is $(cat imageid.txt)"
- |-
curl -X PATCH https://api.heroku.com/apps/$HEROKU_APP_NAME/formation --header "Content-Type: application/json" --header "Accept: application/vnd.heroku+json; version=3.docker-releases" --header "Authorization: Bearer ${HEROKU_TOKEN}" --data '{ "updates": [ { "type": "web", "docker_image": "'$(cat imageid.txt)'" } ] }'
only:
- develop
- master
except:
- tags
release-image:
stage: release
script:
- docker build --pull -f Dockerfile --iidfile imageid.txt -t $CONTAINER_RELEASE_IMAGE .
- docker push $CONTAINER_RELEASE_IMAGE
only:
- tags