Use ci template
This commit is contained in:
parent
96abf0536a
commit
a9b43a5293
|
|
@ -3,69 +3,21 @@ stages:
|
||||||
- test
|
- test
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
kaniko:
|
include:
|
||||||
stage: build
|
- project: 'turniere/turniere-infra'
|
||||||
image:
|
file: '/ci/pipeline.yaml'
|
||||||
name: gcr.io/kaniko-project/executor:debug
|
|
||||||
entrypoint: [""]
|
|
||||||
script:
|
|
||||||
- mkdir -p /kaniko/.docker
|
|
||||||
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
|
|
||||||
- |
|
|
||||||
for env in production development test; do
|
|
||||||
/kaniko/executor --context "${CI_PROJECT_DIR}" \
|
|
||||||
--dockerfile "${CI_PROJECT_DIR}/docker/${env}/Dockerfile" \
|
|
||||||
--destination "${CI_REGISTRY_IMAGE}/${env}:latest" \
|
|
||||||
--destination "${CI_REGISTRY_IMAGE}/${env}/commits:${CI_COMMIT_SHA}" \
|
|
||||||
--destination "${CI_REGISTRY_IMAGE}/${env}/refs:${CI_COMMIT_REF_SLUG}" \
|
|
||||||
--build-arg base_commit="$CI_COMMIT_SHA"
|
|
||||||
done
|
|
||||||
|
|
||||||
rails spec:
|
rails spec:
|
||||||
stage: test
|
stage: test
|
||||||
image: $CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA
|
image: $CI_REGISTRY_IMAGE/test/commits:$CI_COMMIT_SHA
|
||||||
only:
|
rules:
|
||||||
changes:
|
- changes:
|
||||||
- '**/*.rb'
|
- '**/*.rb'
|
||||||
- 'Gemfile'
|
- 'Gemfile'
|
||||||
- 'Gemfile.lock'
|
- 'Gemfile.lock'
|
||||||
except:
|
- if: $SKIP_TEST
|
||||||
variables:
|
when: never
|
||||||
- $SKIP_TEST
|
|
||||||
script:
|
script:
|
||||||
- cd /app
|
- cd /app
|
||||||
- bundle exec rails db:migrate
|
- bundle exec rails db:migrate
|
||||||
- bundle exec rails spec
|
- bundle exec rails spec
|
||||||
|
|
||||||
kubernetes:
|
|
||||||
tags:
|
|
||||||
- turniere-deploy
|
|
||||||
stage: deploy
|
|
||||||
only:
|
|
||||||
refs:
|
|
||||||
- master
|
|
||||||
variables:
|
|
||||||
- $FORCE_DEPLOY
|
|
||||||
image: ruby
|
|
||||||
variables:
|
|
||||||
KUBERNETES_SERVICE_ACCOUNT_OVERWRITE: gitlab-deploy
|
|
||||||
script:
|
|
||||||
- setup-kubectl
|
|
||||||
- krane render -f kubernetes --current-sha "$CI_COMMIT_SHA" | krane deploy turniere-backend-dev local -f kubernetes/secrets.ejson -
|
|
||||||
|
|
||||||
deploy_watchtower:
|
|
||||||
stage: deploy
|
|
||||||
only:
|
|
||||||
refs:
|
|
||||||
- master
|
|
||||||
variables:
|
|
||||||
- $FORCE_DEPLOY
|
|
||||||
image: docker
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
script:
|
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
||||||
- docker pull $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA
|
|
||||||
- docker tag $CI_REGISTRY_IMAGE/production/commits:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE/production:deploy
|
|
||||||
- docker push $CI_REGISTRY_IMAGE/production:deploy
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue