Add .gitlab-ci.yml
This commit is contained in:
parent
d48902551d
commit
e9a53cf867
|
|
@ -0,0 +1,36 @@
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
rails spec:
|
||||||
|
stage: test
|
||||||
|
image: ruby:2.6.2
|
||||||
|
script:
|
||||||
|
- bundle install --path /cache
|
||||||
|
- bundle exec rails db:migrate RAILS_ENV=test
|
||||||
|
- bundle exec rails spec
|
||||||
|
|
||||||
|
kaniko:
|
||||||
|
stage: build
|
||||||
|
image:
|
||||||
|
name: gcr.io/kaniko-project/executor:debug
|
||||||
|
entrypoint: [""]
|
||||||
|
script:
|
||||||
|
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
|
||||||
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||||
|
|
||||||
|
kubernetes:
|
||||||
|
stage: deploy
|
||||||
|
image: ruby
|
||||||
|
variables:
|
||||||
|
KUBERNETES_SERVICE_ACCOUNT_OVERWRITE: gitlab-deploy
|
||||||
|
script:
|
||||||
|
- 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/bin/kubectl
|
||||||
|
- kubectl config set-cluster k8s --server="https://kubernetes.default.svc" --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||||
|
- kubectl config set-credentials sa --token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
|
||||||
|
- kubectl config set-context local --cluster=k8s --user=sa --namespace=turniere
|
||||||
|
- gem install kubernetes-deploy
|
||||||
|
- REVISION=$CI_COMMIT_SHA kubernetes-deploy --template-dir kubernetes turniere local
|
||||||
Loading…
Reference in New Issue