Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
batazor committed Feb 22, 2018
1 parent b127777 commit e7346ac
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 47 deletions.
52 changes: 5 additions & 47 deletions ops/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,8 @@
.job_template_build: &job_build
type: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
when: on_success

.job_template_best_practices: &job_best_practices
image: node:8-alpine
type: best_practices
before_script:
- npm i --ignore-scripts
only:
- tags
allow_failure: true

.job_template_deploy: &job_deploy
type: deploy
script:
- export DEPLOYS=$(helm ls | grep $RELEASE_NAME | wc -l)
- if [ ${DEPLOYS} -eq 0 ]; then
helm --kube-context $HELM_NAMESPACE install
--name $RELEASE_NAME
--namespace=$CI_PROJECT_NAMESPACE
--set CI_PROJECT_NAME=$CI_PROJECT_NAME
--set CI_PIPELINE_ID=$CI_PIPELINE_ID
--set CI_BUILD_ID=$CI_BUILD_ID
--set image.tag=$CI_COMMIT_TAG
--set CI_COMMIT_SHA=$CI_COMMIT_SHA
$HELM_PATH;
else
helm --kube-context $HELM_NAMESPACE upgrade $RELEASE_NAME $HELM_PATH
--namespace=$CI_PROJECT_NAMESPACE
--set CI_PROJECT_NAME=$CI_PROJECT_NAME
--set CI_PIPELINE_ID=$CI_PIPELINE_ID
--set CI_BUILD_ID=$CI_BUILD_ID
--set image.tag=$CI_COMMIT_TAG
--set CI_COMMIT_SHA=$CI_COMMIT_SHA;
fi
except:
- branches
when: manual

.job_template_publish: &job_publish
type: publish
except:
- branches
when: on_success
include:
- '/template_ci/job_best_practices.yml'
- '/template_ci/job_build.yml'
- '/template_ci/job_deploy.yml'
- '/template_ci/job_publish.yml'

image: docker:latest
before_script:
Expand Down
8 changes: 8 additions & 0 deletions ops/template_ci/job_best_practices.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.job_template_best_practices: &job_best_practices
image: node:8-alpine
type: best_practices
before_script:
- npm i --ignore-scripts
only:
- tags
allow_failure: true
5 changes: 5 additions & 0 deletions ops/template_ci/job_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.job_template_build: &job_build
type: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
when: on_success
26 changes: 26 additions & 0 deletions ops/template_ci/job_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.job_template_deploy: &job_deploy
type: deploy
script:
- export DEPLOYS=$(helm ls | grep $RELEASE_NAME | wc -l)
- if [ ${DEPLOYS} -eq 0 ]; then
helm --kube-context $HELM_NAMESPACE install
--name $RELEASE_NAME
--namespace=$CI_PROJECT_NAMESPACE
--set CI_PROJECT_NAME=$CI_PROJECT_NAME
--set CI_PIPELINE_ID=$CI_PIPELINE_ID
--set CI_BUILD_ID=$CI_BUILD_ID
--set image.tag=$CI_COMMIT_TAG
--set CI_COMMIT_SHA=$CI_COMMIT_SHA
$HELM_PATH;
else
helm --kube-context $HELM_NAMESPACE upgrade $RELEASE_NAME $HELM_PATH
--namespace=$CI_PROJECT_NAMESPACE
--set CI_PROJECT_NAME=$CI_PROJECT_NAME
--set CI_PIPELINE_ID=$CI_PIPELINE_ID
--set CI_BUILD_ID=$CI_BUILD_ID
--set image.tag=$CI_COMMIT_TAG
--set CI_COMMIT_SHA=$CI_COMMIT_SHA;
fi
except:
- branches
when: manual
5 changes: 5 additions & 0 deletions ops/template_ci/job_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.job_template_publish: &job_publish
type: publish
except:
- branches
when: on_success

0 comments on commit e7346ac

Please sign in to comment.