-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
34 lines (29 loc) · 836 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
image: docker:latest
services:
- docker:dind
stages:
- build
- deploy
variables:
DOCKER_DRIVER: overlay
IMAGE_TAG: $CI_REGISTRY_IMAGE
build:
stage: build
only:
- master
script:
- docker build -f Dockerfile.prod -t $IMAGE_TAG:${CI_COMMIT_SHA:0:8} .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $IMAGE_TAG:${CI_COMMIT_SHA:0:8}
deploy_production:
stage: deploy
image: devfelipereis/rancher-cli-k8s:latest
environment:
name: production
url: https://example.com
when: on_success
only:
- master
script:
- rancher login $RANCHER_SERVER_URL --token $RANCHER_API_TOKEN --context $RANCHER_PROJECT_ID
- rancher kubectl --namespace=$RANCHER_PROJECT_NAMESPACE set image deployment/$DEPLOYMENT_NAME $DEPLOYMENT_NAME=$IMAGE_TAG:${CI_COMMIT_SHA:0:8}