1 Star 0 Fork 0

Robin/ethereum-studio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
superblocks.yaml 4.21 KB
一键复制 编辑 原始数据 按行查看 历史
Ostap Kravchuk 提交于 2020-05-07 13:06 . Use one cluster for stage and prod
# Vanilla configuration
# Start with a minimal configuration that you can customize to build your code
# http://superblocks.com/docs/configuration/configuration-introduction/#section=configuration
version: 1
jobs:
push_to_docker_registry:
image: docker:18.09.7
services:
- docker:18.09.7-dind
script:
- echo "$GITHUB_REGISTRY_TOKEN" | docker login docker.pkg.github.com --username $GITHUB_REGISTRY_USER --password-stdin
- docker build --build-arg BUILD=build -t $GITHUB_REGISTRY_IMAGE:$SUPER_COMMIT_SHA1 .
- docker push $GITHUB_REGISTRY_IMAGE:$SUPER_COMMIT_SHA1
deploy_to_staging:
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 --server=$K8S_SERVER --insecure-skip-tls-verify=true
- kubectl config set clusters.k8s.certificate-authority-data $K8S_CERTIFICATE_AUTHORITY_DATA
- kubectl config set-credentials $K8S_USER_NAME --token=$K8S_USER_TOKEN
- kubectl config set-context staging --cluster=$K8S_CLUSTER_NAME --user=$K8S_USER_NAME --namespace=staging
- kubectl config use-context staging
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret docker-registry $CI_PROJECT_NAME-github-registry --docker-server=$CI_REGISTRY --docker-username=$GITHUB_REGISTRY_USER --docker-password=$GITHUB_REGISTRY_TOKEN -o yaml --dry-run)" | kubectl apply -f -'
# pass env variables, which names start with "STAGING_" to application running in kubernetes
- env | sed -n "s/^STAGING_\(.*\)$/\1/p" > k8s_prefixed_variables
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret generic $CI_PROJECT_NAME-secret --from-env-file k8s_prefixed_variables -o yaml --dry-run)" | kubectl apply -f -'
- rm k8s_prefixed_variables
# generate deployment file
- sed 's _APP_NAME_ '"$CI_PROJECT_NAME"' g; s _CONTAINER_IMAGE_ '"$GITHUB_REGISTRY_IMAGE:$SUPER_COMMIT_SHA1"' g' kubernetes.tpl.yml > kubernetes.yml;
- kubectl apply -f kubernetes.yml\
deploy_to_prod:
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 --server=$K8S_SERVER --insecure-skip-tls-verify=true
- kubectl config set clusters.k8s.certificate-authority-data $K8S_CERTIFICATE_AUTHORITY_DATA
- kubectl config set-credentials $K8S_USER_NAME --token=$K8S_USER_TOKEN
- kubectl config set-context prodution --cluster=$K8S_CLUSTER_NAME --user=$K8S_USER_NAME
- kubectl config use-context prodution
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret docker-registry $CI_PROJECT_NAME-github-registry --docker-server=$CI_REGISTRY --docker-username=$GITHUB_REGISTRY_USER --docker-password=$GITHUB_REGISTRY_TOKEN -o yaml --dry-run)" | kubectl apply -f -'
# pass env variables, which names start with "PROD_" to application running in kubernetes
- env | sed -n "s/^PROD_\(.*\)$/\1/p" > k8s_prefixed_variables
- 'printf "apiVersion: v1\nkind: Secret\n$(kubectl create secret generic $CI_PROJECT_NAME-secret --from-env-file k8s_prefixed_variables -o yaml --dry-run)" | kubectl apply -f -'
- rm k8s_prefixed_variables
# generate deployment file
- sed 's _APP_NAME_ '"$CI_PROJECT_NAME"' g; s _CONTAINER_IMAGE_ '"$GITHUB_REGISTRY_IMAGE:$SUPER_COMMIT_SHA1"' g' kubernetes.tpl.yml > kubernetes.yml;
- kubectl apply -f kubernetes.yml
stages:
- build:
jobs:
- push_to_docker_registry:
filters:
only:
- master
- deploy_staging:
jobs:
- deploy_to_staging:
filters:
only:
- master
- deploy_prod:
jobs:
- deploy_to_prod:
when: manual
filters:
only:
- master
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/luweb/ethereum-studio.git
git@gitee.com:luweb/ethereum-studio.git
luweb
ethereum-studio
ethereum-studio
master

搜索帮助