forked from SuperblocksHQ/ethereum-studio
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
45 lines (42 loc) · 2.05 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
stages:
- build_dev
- deploy_dev
variables:
CONTAINER_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
CONTAINER_IMAGE_DEV: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA.dev
push to docker registry dev:
stage: build_dev
image: docker:latest
services:
- docker:dind
script:
- echo $CI_REGISTRY
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build --build-arg BUILD=build:dev -t $CONTAINER_IMAGE_DEV .
- docker push $CONTAINER_IMAGE_DEV
environment:
name: dev
only:
- master
deploy to dev:
stage: deploy_dev
image: alpine
script:
- apk add --no-cache curl
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- kubectl config set-cluster $K8S_CLUSTER_NAME_DEV --server=$K8S_SERVER_DEV --insecure-skip-tls-verify=true
- kubectl config set clusters.k8s.certificate-authority-data $K8S_CERTIFICATE_AUTHORITY_DATA_DEV
- kubectl config set-credentials $K8S_USER_NAME_DEV --token=$K8S_USER_TOKEN_DEV
- kubectl config set-context $K8S_CLUSTER_NAME_DEV --cluster=$K8S_CLUSTER_NAME_DEV --user=$K8S_USER_NAME_DEV
- kubectl config use-context $K8S_CLUSTER_NAME_DEV
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret docker-registry $CI_PROJECT_NAME-gitlab-registry --docker-server=$CI_REGISTRY --docker-username=$CI_DEPLOY_USER --docker-password=$CI_DEPLOY_PASSWORD --docker-email=$GITLAB_USER_EMAIL -o yaml --dry-run)" | kubectl apply -f -'
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret generic $CI_PROJECT_NAME-secret -o yaml --dry-run)" | kubectl apply -f -'
- sed 's _APP_NAME_ '"$CI_PROJECT_NAME"' g; s _CONTAINER_IMAGE_ '"$CONTAINER_IMAGE_DEV"' g' kubernetes.tpl.yml > kubernetes.yml;
- kubectl apply -f kubernetes.yml
environment:
name: dev
url: https://dashboard-dev.superblocks.com
only:
- master