Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
Offer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
mashplace
backend
Offer
Commits
8514d4f5
Commit
8514d4f5
authored
4 years ago
by
George Falileev
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'feature/MRM-2415'
ci See merge request mashroom/backend/offer!149
parents
c6484f9c
f65201e6
Branches
feature/MRM-2415
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+3
-153
3 additions, 153 deletions
.gitlab-ci.yml
with
3 additions
and
153 deletions
.gitlab-ci.yml
+
3
−
153
View file @
8514d4f5
stages
:
-
test
-
build
-
deploy
#cache:
# key: "${CI_PROJECT_NAME}"
# paths:
# - .go-cicd/
services
:
-
name
:
docker:dind
alias
:
docker-dind
variables
:
IMAGE_REGISTRY
:
"
registry.gitlab.okta-solutions.com"
IMAGE_PATH
:
"
${CI_PROJECT_PATH}"
IMAGE_TAG
:
"
${CI_PIPELINE_ID}"
DOCKER_HOST
:
"
tcp://127.0.0.1:2375"
GO111MODULE
:
"
on"
CGO_ENABLED
:
"
0"
GOOS
:
"
linux"
GOARCH
:
"
amd64"
GOPATH
:
"
${CI_PROJECT_DIR}/.go-cicd"
GOBIN
:
"
${CI_PROJECT_DIR}"
GOPRIVATE
:
"
gitlab.okta-solutions.com/*"
before_script
:
-
export PATH="$GOBIN:$PATH"
test
:
stage
:
test
only
:
-
merge_request
-
master
-
staging
-
testing
-
beta
-
/^b[0-9]+\.[0-9]+\.[0-9]+/
image
:
registry.gitlab.okta-solutions.com/mashroom/backend/common/gobuild:1.14.3
script
:
-
go mod download
-
go mod vendor
-
go generate -v tools.go
-
go generate -v
-
grep -q -r 'ProtoReflect()' api/ || { echo "ProtoReflect() functions are missing in API, check your protoc and protoc-gen-go version"; exit 1; }
-
CHECK_EXCLUDE="^.*\/vendor\/" gocheck.sh
-
RUN_TESTS=1 go test -v ./...
build
:
stage
:
build
only
:
-
merge_request
-
master
-
staging
-
testing
-
beta
-
/^b[0-9]+\.[0-9]+\.[0-9]+/
image
:
registry.gitlab.okta-solutions.com/mashroom/backend/common/gobuild:1.14.3
script
:
-
go mod download
-
go mod vendor
-
go generate -v tools.go
-
go generate -v
-
go install -tags netgo -ldflags '-w -extldflags "-static"' -v ./cmd/...
-
cp /etc/ssl/certs/ca-certificates.crt .
-
echo "Logging to Container Registry..."
-
docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
-
echo "Building Dockerfile application..."
-
docker build -f Dockerfile.cicd -t ${IMAGE_REGISTRY}/${IMAGE_PATH}:${IMAGE_TAG} .
-
echo "Pushing to the Container Registry..."
-
docker push ${IMAGE_REGISTRY}/${IMAGE_PATH}:${IMAGE_TAG}
-
|
ENV_TYPE="staging"
if [ "$CI_COMMIT_REF_NAME" = "testing" ]; then
ENV_TYPE="testing"
elif [ "$CI_COMMIT_REF_NAME" = "beta" ]; then
ENV_TYPE="beta"
else
case "$CI_COMMIT_REF_NAME" in
b*.*.*) ENV_TYPE="beta-${CI_COMMIT_TAG}"
esac
fi
docker tag ${IMAGE_REGISTRY}/${IMAGE_PATH}:${IMAGE_TAG} ${IMAGE_REGISTRY}/${IMAGE_PATH}:${ENV_TYPE}
echo "Pushing ${ENV_TYPE} to Container Registry..."
docker push ${IMAGE_REGISTRY}/${IMAGE_PATH}:${ENV_TYPE}
deploy_beta_manual
:
stage
:
deploy
image
:
dtzar/helm-kubectl:latest
cache
:
{}
when
:
manual
only
:
-
/^b[0-9]+\.[0-9]+\.[0-9]+/
script
:
-
export ENV_TYPE="beta"
-
echo "Clonning charts"
-
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.okta-solutions.com/mashroom/devops/charts
-
helm repo remove stable ||
true
-
helm repo remove local ||
true
-
find charts -name requirements.yaml -exec sh -c 'cd "$(dirname "{}")" && helm dependencies update' \;
-
echo "Setting credentials"
-
kubectl config set-cluster prod --server "${CLUSTER_PRODUCTION_URL}"
-
kubectl config set clusters.prod.certificate-authority-data "${CLUSTER_PRODUCTION_CA}"
-
kubectl config set-credentials cicd --token "${CLUSTER_PRODUCTION_TOKEN}"
-
kubectl config set-context prod-cicd --cluster prod --user cicd
-
kubectl config use-context prod-cicd
-
echo "Deploy to ${ENV_TYPE} cluster"
-
helm upgrade --namespace ${ENV_TYPE}-mashroom --install ${ENV_TYPE}-mashroom-${CI_PROJECT_NAME} charts/mashroom/${CI_PROJECT_NAME} -f charts/mashroom/${CI_PROJECT_NAME}/values-base.yaml -f charts/mashroom/${CI_PROJECT_NAME}/values-${ENV_TYPE}.yaml --set "mashroom.services.${CI_PROJECT_NAME}.image.tag=${IMAGE_TAG}"
deploy_staging
:
stage
:
deploy
image
:
dtzar/helm-kubectl:latest
cache
:
{}
only
:
-
master
script
:
-
export ENV_TYPE="staging"
-
echo "Clonning charts"
-
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.okta-solutions.com/mashroom/devops/charts
-
helm repo remove stable ||
true
-
helm repo remove local ||
true
-
find charts -name requirements.yaml -exec sh -c 'cd "$(dirname "{}")" && helm dependencies update' \;
-
echo "Setting credentials"
-
kubectl config set-cluster "${ENV_TYPE}" --server "${CLUSTER_STAGING_URL}"
-
kubectl config set "clusters.${ENV_TYPE}.certificate-authority-data" "${CLUSTER_STAGING_CA}"
-
kubectl config set-credentials cicd --token "${CLUSTER_STAGING_TOKEN}"
-
kubectl config set-context "${ENV_TYPE}-cicd" --cluster ${ENV_TYPE} --user cicd
-
kubectl config use-context "${ENV_TYPE}-cicd"
-
echo "Deploy to ${ENV_TYPE} cluster"
-
helm upgrade --namespace ${ENV_TYPE}-mashroom --install ${ENV_TYPE}-mashroom-${CI_PROJECT_NAME} charts/mashroom/${CI_PROJECT_NAME} -f charts/mashroom/${CI_PROJECT_NAME}/values-base.yaml -f charts/mashroom/${CI_PROJECT_NAME}/values-${ENV_TYPE}.yaml --set "mashroom.services.${CI_PROJECT_NAME}.image.tag=${IMAGE_TAG}"
deploy_testing
:
stage
:
deploy
image
:
dtzar/helm-kubectl:latest
cache
:
{}
only
:
-
testing
script
:
-
export ENV_TYPE="testing"
-
echo "Clonning charts"
-
git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.okta-solutions.com/mashroom/devops/charts
-
helm repo remove stable ||
true
-
helm repo remove local ||
true
-
find charts -name requirements.yaml -exec sh -c 'cd "$(dirname "{}")" && helm dependencies update' \;
-
echo "Setting credentials"
-
kubectl config set-cluster "${ENV_TYPE}" --server "${CLUSTER_STAGING_URL}"
-
kubectl config set "clusters.${ENV_TYPE}.certificate-authority-data" "${CLUSTER_STAGING_CA}"
-
kubectl config set-credentials cicd --token "${CLUSTER_STAGING_TOKEN}"
-
kubectl config set-context "${ENV_TYPE}-cicd" --cluster ${ENV_TYPE} --user cicd
-
kubectl config use-context "${ENV_TYPE}-cicd"
-
echo "Deploy to ${ENV_TYPE} cluster"
-
helm upgrade --namespace ${ENV_TYPE}-mashroom --install ${ENV_TYPE}-mashroom-${CI_PROJECT_NAME} charts/mashroom/${CI_PROJECT_NAME} -f charts/mashroom/${CI_PROJECT_NAME}/values-base.yaml -f charts/mashroom/${CI_PROJECT_NAME}/values-${ENV_TYPE}.yaml --set "mashroom.services.${CI_PROJECT_NAME}.image.tag=${IMAGE_TAG}"
include
:
-
project
:
mashroom/devops/gitlab
file
:
/entrypoint/go/backend-generic.yaml
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment