Skip to content
Snippets Groups Projects
Commit f1fa079b authored by Dobromir Palushev's avatar Dobromir Palushev
Browse files

pipeline multiple updates

* updated workflow rules
* updated job names
* updated container versions
* added a template for gke-initialization
parent 467f9cdb
No related branches found
No related tags found
31 merge requests!36pipeline multiple updates,!35pipeline multiple updates,!33pipeline multiple updates,!32pipeline multiple updates,!30pipeline multiple updates,!28pipeline multiple updates,!27pipeline multiple updates,!26pipeline multiple updates,!25pipeline multiple updates,!24pipeline multiple updates,!23pipeline multiple updates,!22pipeline multiple updates,!21pipeline multiple updates,!20pipeline multiple updates,!19pipeline multiple updates,!18pipeline multiple updates,!17pipeline multiple updates,!16pipeline multiple updates,!15pipeline multiple updates,!14pipeline multiple updates,!12pipeline multiple updates,!11pipeline multiple updates,!10pipeline multiple updates,!9pipeline multiple updates,!8pipeline multiple updates,!7pipeline multiple updates,!6pipeline multiple updates,!5pipeline multiple updates,!4pipeline multiple updates,!3pipeline multiple updates,!2pipeline multiple updates
Pipeline #19101 canceled
This commit is part of merge request !21. Comments created here will be created in the context of that merge request.
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if: >-
$CI_PIPELINE_SOURCE == "push"
&& ($CI_COMMIT_BRANCH == "staging" || $CI_COMMIT_BRANCH == "master")
$CI_COMMIT_BRANCH == "staging" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- when: never
variables:
DOCKER_VERSION: '20.10.12'
K8S_NAMESPACE: 'devops-s22-deployable'
DOCKER_VERSION: '20.10.17'
K8S_VERSION: '1.24'
GOOGLE_CLOUD_SDK_IMAGE_VERSION: '400.0.0'
K8S_NAMESPACE: 'todoapp-devops'
CONTAINER_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}'
stages:
- test
- build
- release
- deploy
job_test-image:
.gke-initialization:
before_script:
- echo $BASE64_GOOGLE_CREDENTIALS | base64 -d > ~/service_account.json
- gcloud auth activate-service-account --key-file ~/service_account.json
- gcloud config set project ${GCP_PROJECT_ID}
- gcloud config set compute/zone ${GCP_COMPUTE_REGION}
- gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke
test-image:
stage: test
tags:
- docker-priviliged
image: docker:$DOCKER_VERSION
image: docker:${DOCKER_VERSION}
services:
- name: docker:$DOCKER_VERSION-dind
- name: docker:${DOCKER_VERSION}-dind
script:
- docker build
--tag "${CONTAINER_TAG}-test"
--target=test
"./"
after_script:
- docker image rm --force "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}"
- docker image rm --force "${CONTAINER_TAG}-test"
job_build-image:
build-image:
stage: build
needs:
- 'job_test-image'
rules:
- if: $CI_COMMIT_BRANCH != "staging" && $CI_COMMIT_BRANCH != "master"
when: 'never'
- 'test-image'
tags:
- docker-priviliged
image: docker:$DOCKER_VERSION
image: docker:${DOCKER_VERSION}
services:
- name: docker:$DOCKER_VERSION-dind
- name: docker:${DOCKER_VERSION}-dind
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- SERVER_PUBLIC_URL=""
- DB_HOST=""
- docker build
- docker image build
--tag "${CONTAINER_TAG}"
--build-arg JWT_SECRET=${JWT_SECRET}
--build-arg SERVER_PUBLIC_URL=${SERVER_PUBLIC_URL}
--build-arg DB_HOST=${DB_HOST}
"./"
"./app"
# - docker image build
# --tag "${CONTAINER_TAG}-google-sdk"
# "./gcloud-image"
- docker push "${CONTAINER_TAG}"
# - docker push "${CONTAINER_TAG}-google-sdk"
after_script:
- docker image rm --force "${CONTAINER_TAG}"
# - docker image rm --force "${CONTAINER_TAG}-google-sdk"
create-release_image:
stage: release
rules:
- if: $CI_COMMIT_REF_NAME =~ /main/
when: 'always'
tags:
- docker-privileged
image: docker:${DOCKER_VERSION}
services:
- name: docker:${DOCKER_VERSION}-dind
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker push "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}"
- docker pull "${CONTAINER_TAG}"
script:
- VERSION=$(cat ./app/client/package.json | docker run --interactive stedolan/jq --raw-output '.version')
- docker tag "${CONTAINER_TAG}" "${CI_REGISTRY_IMAGE}:${VERSION}"
- docker push "${CI_REGISTRY_IMAGE}:${VERSION}"
after_script:
- docker image rm --force "${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}"
- docker image rm --force
$(docker images --format '{{.Repository}}{{.Tag}}' | grep '${CI_REGISTRY_IMAGE}')
# create-release_tag:
# stage: release
# needs:
# - 'create-release_image'
# rules:
# - if: $CI_COMMIT_REF_NAME =~ /main/
# when: 'always'
# tags:
# - docker-privileged
# image: docker:${DOCKER_VERSION}-git
# services:
# - name: docker:${DOCKER_VERSION}-dind
# script:
# - VERSION=$(cat ./src/package.json | docker run --interactive stedolan/jq --raw-output '.version')
# - echo ${VERSION}
# #- git tag "v${VERSION}" && git push origin "v${VERSION}"
job_deploy-image:
deploy-image:
extends: .gke-initialization
stage: deploy
needs:
- 'job_build-image'
- 'build-image'
rules:
- if: $CI_COMMIT_REF_NAME =~ /staging/
when: 'always'
variables:
ENVIRONMENT_NAME: 'staging'
- if: $CI_COMMIT_REF_NAME !~ /staging/
- if: $CI_COMMIT_REF_NAME !~ /main/
when: 'always'
variables:
ENVIRONMENT_NAME: 'prod'
ENVIRONMENT_NAME: 'production'
tags:
- docker
image:
name: k8s-image
entrypoint: ['']
image: google/cloud-sdk:${GOOGLE_CLOUD_SDK_IMAGE_VERSION}
script:
# - IMAGE="${CI_REGISTRY_IMAGE}:${VERSION}"
- kubectl apply
--kubeconfig ${SECRET_KUBECONFIG_PATH}
--namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
--kustomize -
- VERSION="${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}"
- IMAGE="${CI_REGISTRY_IMAGE}:${VERSION}"
- cd "app/k8s-manifests"
- kubectl apply secrets.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply gitlab-registry-credentials.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply configmap.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply deployment.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply service.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply ingress.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment