Verified Commit af4ca7c8 authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Add publish and convert to kubernetes build

parent 17c0af14
Pipeline #315 waiting for manual action with stages
in 9 minutes and 9 seconds
stages:
- build-app
- deploy-prepare
- deploy-validate
- deploy-plan
- deploy-execute
- deploy-destroy
- prepare
- validate
- build
- deploy
- publish
- destroy
cache:
paths:
- .go
app:prepare:
image: alpine/git:v2.26.2
stage: prepare
tags:
- kubernetes
- cluster
script:
- echo "VERSION=$(git describe | sed s!release/!!g)" > variables.env
artifacts:
reports:
dotenv:
- variables.env
build:
stage: build-app
app:build:
cache:
key: go
paths:
- .go
image: quay.io/buildah/stable:v1.16.0
needs:
- job: app:prepare
artifacts: true
stage: build
tags:
- kubernetes
- cluster
script:
- buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- ./build-docker.sh $CI_REGISTRY_IMAGE
after_script:
- chmod u+rwx .go -R
artifacts:
paths:
- playlist.version.auto.tfvars
reports:
junit: target/reports/tests.xml
cobertura: target/reports/cobertura.xml
include: /infra/.gitlab-ci.yml
\ No newline at end of file
include: /infra/.gitlab-ci.yml
app:publish:dev:
cache:
key: node
paths:
- node_modules
image: node:15.2.1-alpine3.11
stage: publish
needs:
- job: deploy:apply:dev
artifacts: true
tags:
- kubernetes
- cluster
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
script:
- cd apollo
- yarn install --lockfile-only
- yarn run push --serviceName=playlist --serviceURL=$SERVICE_URL --endpoint=$SERVICE_URL --variant=development
\ No newline at end of file
module.exports = {
service: {}
}
\ No newline at end of file
{
"dependencies": {
"apollo": "^2.31.1"
},
"scripts": {
"push": "apollo service:push"
}
}
This diff is collapsed.
.deploy_template: &deploy_tpl
image: registry.gitlab.com/gitlab-org/terraform-images/releases/0.13:v0.2.4
image: registry.gitlab.com/gitlab-org/terraform-images/releases/0.13:v0.3.3
tags:
- kubernetes
- cluster
variables:
TF_ROOT: ${CI_PROJECT_DIR}/infra
TF_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${CI_ENVIRONMENT_NAME}
cache:
key: production
key: deploy-${CI_COMMIT_REF_SLUG}
paths:
- ${TF_ROOT}/.terraform
before_script:
- cd ${TF_ROOT}
- ./terraform-gitlab
- ./terraform-gitlab.sh
init:
deploy:init:
<<: *deploy_tpl
stage: deploy-prepare
stage: prepare
script:
- gitlab-terraform init
validate:
deploy:validate:
<<: *deploy_tpl
needs:
- init
stage: deploy-validate
- job: deploy:init
artifacts: false
stage: validate
script:
- gitlab-terraform validate
plan-dev:
deploy:plan:dev:
<<: *deploy_tpl
needs:
- build
- validate
stage: deploy-plan
- job: deploy:validate
artifacts: false
- job: app:prepare
artifacts: true
stage: build
environment:
name: development
action: prepare
auto_stop_in: 2 days
auto_stop_in: 7 days
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
when: on_success
script:
- cp ../playlist.version.auto.tfvars .
- echo "playlist_version = \"$VERSION\"" > playlist.version.auto.tfvars
- gitlab-terraform plan
- gitlab-terraform plan-json
artifacts:
name: plan-dev
paths:
- ${TF_ROOT}/plan.cache
- ${TF_ROOT}/playlist.version.auto.tfvars
apply-dev:
deploy:apply:dev:
<<: *deploy_tpl
needs:
- plan-dev
- build
stage: deploy-execute
- job: deploy:plan:dev
artifacts: true
- job: app:build
artifacts: false
stage: deploy
environment:
name: development
on_stop: stop-dev
on_stop: deploy:stop:dev
auto_stop_in: 7 days
script:
- cp ../playlist.version.auto.tfvars .
- gitlab-terraform apply
dependencies:
- plan-dev
- build
- echo -n "SERVICE_URL=$(gitlab-terraform output -json graphql-service | jq -r '"http://"+.address+":"+(.port | tostring)+"/"')" > deploy-info.env
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
when: manual
when: on_success
artifacts:
reports:
dotenv:
- ${TF_ROOT}/deploy-info.env
stop-dev:
deploy:stop:dev:
<<: *deploy_tpl
needs:
- apply-dev
stage: deploy-destroy
- job: deploy:apply:dev
artifacts: false
stage: destroy
script:
- gitlab-terraform init
- gitlab-terraform destroy -auto-approve
......
......@@ -15,11 +15,6 @@ terraform {
EOB
cat << EOC > details.auto.tfvars # language=terraform
//player = {
// address = "${ENV}-player.${NS}"
// port = "2000"
//}
player_state_address = "${CI_API_V4_URL:-}/projects/${player_project_id:-131}/terraform/state/${ENV}"
environment = "${ENV}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment