Last active
October 18, 2018 14:05
-
-
Save devfelipereis/9f02455024952c41022ea5c62d7196ad to your computer and use it in GitHub Desktop.
gitlab ci deploy rancher k8s example (annotations) [NOT RECOMMED - CAN NOT ROLLBACK]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
services: | |
- docker:dind | |
stages: | |
- build | |
- deploy | |
variables: | |
DOCKER_DRIVER: overlay | |
IMAGE_TAG: $CI_REGISTRY_IMAGE:master | |
DEPLOYMENT_NAME: app | |
build: | |
stage: build | |
only: | |
- master | |
script: | |
- docker build -f Dockerfile.prod -t $IMAGE_TAG . | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
- docker push $IMAGE_TAG | |
deploy_production: | |
stage: deploy | |
image: devfelipereis/rancher-cli-k8s:latest | |
environment: | |
name: production | |
url: http://example.xip.io/ | |
when: manual | |
only: | |
- master | |
script: | |
- rancher login $RANCHER_SERVER_URL --token $RANCHER_API_TOKEN --context $RANCHER_PROJECT_ID | |
- rancher kubectl --namespace=$RANCHER_PROJECT_NAMESPACE patch deployment $DEPLOYMENT_NAME --type=strategic | |
-p '{"spec":{"template":{"metadata":{"annotations":{"app.ci.commitsha":"'${CI_COMMIT_SHA:0:8}'"}}}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment