-
-
Save heartshare/88ad3194aaa18399098b8a90283e304f to your computer and use it in GitHub Desktop.
This file contains 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
variables: | |
DOCKER_DRIVER: "overlay2" | |
REPOSITORY_URL: "changeme:latest" | |
stages: | |
- build | |
- deploy | |
services: | |
- docker:dind | |
build-app: | |
stage: build | |
only: | |
- master | |
script: | |
- mkdir -p $HOME/.docker | |
- apk add --no-cache curl jq python py-pip | |
- pip install awscli | |
- $(aws ecr get-login --no-include-email --region ap-southeast-1) | |
- docker info | |
- docker build -t ${REPOSITORY_URL} . | |
- docker push ${REPOSITORY_URL} | |
deploy-app: | |
stage: deploy | |
image: alpine | |
only: | |
- master | |
script: | |
- apk add --no-cache curl | |
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | |
- chmod +x ./kubectl | |
- mv ./kubectl /usr/local/bin/kubectl | |
- kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true | |
- kubectl config set-credentials admin --token="$KUBE_TOKEN" | |
- kubectl config set-context default --cluster=k8s --user=admin | |
- kubectl config use-context default | |
- cd k8s && kubectl apply -f - | |
- kubectl patch deployment backend -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"`date +'%s'`\"}}}}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment