代码拉取完成,页面将自动刷新
# 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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。