From 90e0057b612f1edbcf67b87bd3661fc1fca7363d Mon Sep 17 00:00:00 2001 From: mingshun Date: Thu, 27 Feb 2020 10:46:47 +0800 Subject: [PATCH 1/5] Add Tencent Cloud starter workflow --- ci/properties/tencent.properties.json | 6 +++ ci/tencent.yml | 76 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 ci/properties/tencent.properties.json create mode 100644 ci/tencent.yml diff --git a/ci/properties/tencent.properties.json b/ci/properties/tencent.properties.json new file mode 100644 index 0000000..d93a25e --- /dev/null +++ b/ci/properties/tencent.properties.json @@ -0,0 +1,6 @@ +{ + "name": "Build and Deploy to TKE", + "description": "Build a Docker container, publish it to TKE Registry, and deploy to TKE cluster.", + "iconName": "tencentcloud", + "categories": ["Dockerfile"] +} diff --git a/ci/tencent.yml b/ci/tencent.yml new file mode 100644 index 0000000..8b937bc --- /dev/null +++ b/ci/tencent.yml @@ -0,0 +1,76 @@ +# This workflow will build a docker container, publish it to TKE Registry, and deploy it to TKE. +# +# To configure this workflow: +# +# 1. Ensure that your repository contains the necessary configuration for your Tencent Kubernetes Engine cluster, +# including deployment.yml, kustomization.yml, service.yml, etc. +# +# 2. Set up secrets in your workspace: +# - TENCENT_CLOUD_SECRET_ID with Tencent Cloud secret id +# - TENCENT_CLOUD_SECRET_KEY with Tencent Cloud secret key +# - TENCENT_CLOUD_ACCOUNT_ID with Tencent Cloud account id +# - TKE_REGISTRY_PASSWORD with TKE registry password +# +# 3. Change the values for the TKE_IMAGE_URL, TKE_REGION, TKE_CLUSTER_ID and DEPLOYMENT_NAME environment variables (below). + +name: Build and Deploy to TKE + +on: + push: + branches: + - master + +# Environment variables available to all jobs and steps in this workflow +env: + TKE_IMAGE_URL: ccr.ccs.tencentyun.com/demo/mywebapp + TKE_REGION: ap-guangzhou + TKE_CLUSTER_ID: cls-mywebapp + DEPLOYMENT_NAME: tke-test + +jobs: + setup-build-publish-deploy: + name: Setup, Build, Publish, and Deploy + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + # Build + - name: Build Docker image + run: | + docker build -t ${TKE_IMAGE_URL}:${GITHUB_SHA} . + + - name: Login TKE Registry + run: | + docker login -u ${{ secrets.TENCENT_CLOUD_ACCOUNT_ID }} -p ${{ secrets.TKE_REGISTRY_PASSWORD }} ${TKE_IMAGE_URL} + + # Push the Docker image to TKE Registry + - name: Publish + run: | + docker push ${TKE_IMAGE_URL}:${GITHUB_SHA} + + - name: Set up Kustomize + run: | + curl -o kustomize --location https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 + chmod u+x ./kustomize + + - name: Set up ~/.kube/config for connecting TKE cluster + uses: TencentCloud/tke-cluster-credential-action@v1 + with: + secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }} + secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }} + tke_region: ${{ env.TKE_REGION }} + cluster_id: ${{ env.TKE_CLUSTER_ID }} + + - name: Switch to TKE context + run: | + kubectl config use-context ${TKE_CLUSTER_ID}-context-default + + # Deploy the Docker image to the TKE cluster + - name: Deploy + run: | + ./kustomize edit set image ${TKE_IMAGE_URL}:${GITHUB_SHA} + ./kustomize build . | kubectl apply -f - + kubectl rollout status deployment/${DEPLOYMENT_NAME} + kubectl get services -o wide \ No newline at end of file From d5e8e87192c1090f4e9c4e2763bafaf138064ce7 Mon Sep 17 00:00:00 2001 From: mingshun Date: Wed, 29 Apr 2020 09:43:42 +0800 Subject: [PATCH 2/5] Add Tencent Cloud icon --- icons/tencentcloud.svg | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 icons/tencentcloud.svg diff --git a/icons/tencentcloud.svg b/icons/tencentcloud.svg new file mode 100644 index 0000000..0dad590 --- /dev/null +++ b/icons/tencentcloud.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + From 03bcd683793b6285482a83f5c16c49ad11143bad Mon Sep 17 00:00:00 2001 From: mingshun Date: Wed, 29 Apr 2020 09:49:34 +0800 Subject: [PATCH 3/5] Rename workflow to be the platform --- ci/properties/tencent.properties.json | 2 +- ci/tencent.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/properties/tencent.properties.json b/ci/properties/tencent.properties.json index d93a25e..1399885 100644 --- a/ci/properties/tencent.properties.json +++ b/ci/properties/tencent.properties.json @@ -1,5 +1,5 @@ { - "name": "Build and Deploy to TKE", + "name": "Tencent Kubernetes Engine", "description": "Build a Docker container, publish it to TKE Registry, and deploy to TKE cluster.", "iconName": "tencentcloud", "categories": ["Dockerfile"] diff --git a/ci/tencent.yml b/ci/tencent.yml index 8b937bc..308a1ee 100644 --- a/ci/tencent.yml +++ b/ci/tencent.yml @@ -13,7 +13,7 @@ # # 3. Change the values for the TKE_IMAGE_URL, TKE_REGION, TKE_CLUSTER_ID and DEPLOYMENT_NAME environment variables (below). -name: Build and Deploy to TKE +name: Tencent Kubernetes Engine on: push: From e5ca8224887e7649b270def58205014b53169e57 Mon Sep 17 00:00:00 2001 From: mingshun Date: Wed, 29 Apr 2020 10:00:35 +0800 Subject: [PATCH 4/5] Change the event that the workflow --- ci/tencent.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/tencent.yml b/ci/tencent.yml index 308a1ee..e0c0a82 100644 --- a/ci/tencent.yml +++ b/ci/tencent.yml @@ -16,9 +16,8 @@ name: Tencent Kubernetes Engine on: - push: - branches: - - master + release: + types: [created] # Environment variables available to all jobs and steps in this workflow env: From c411e74e2305816ff2042179011a265f7574bbd7 Mon Sep 17 00:00:00 2001 From: mingshun Date: Wed, 29 Apr 2020 10:02:53 +0800 Subject: [PATCH 5/5] Modify workflow description --- ci/properties/tencent.properties.json | 2 +- ci/tencent.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/properties/tencent.properties.json b/ci/properties/tencent.properties.json index 1399885..8bbf29f 100644 --- a/ci/properties/tencent.properties.json +++ b/ci/properties/tencent.properties.json @@ -1,6 +1,6 @@ { "name": "Tencent Kubernetes Engine", - "description": "Build a Docker container, publish it to TKE Registry, and deploy to TKE cluster.", + "description": "This workflow will build a docker container, publish and deploy it to Tencent Kubernetes Engine (TKE).", "iconName": "tencentcloud", "categories": ["Dockerfile"] } diff --git a/ci/tencent.yml b/ci/tencent.yml index e0c0a82..2d4ad03 100644 --- a/ci/tencent.yml +++ b/ci/tencent.yml @@ -1,4 +1,4 @@ -# This workflow will build a docker container, publish it to TKE Registry, and deploy it to TKE. +# This workflow will build a docker container, publish and deploy it to Tencent Kubernetes Engine (TKE). # # To configure this workflow: #