Skip to content

Commit

Permalink
cd: auto deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqihao.foliet committed Dec 21, 2023
1 parent 2f1be0f commit 3905ce1
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Upgrade

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
Expand All @@ -14,23 +14,17 @@ on:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
USERNAME: xhpolaris
# github.repository as <account>/<repo>
IMAGE_NAME: meowchat-core-api
NAMESPACE: xh-polaris-test
KUBE_VERSION: v1.24.15

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -71,4 +65,21 @@ jobs:
tags: ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Setup Kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ env.KUBE_VERSION }}

- name: Deploy
run: |
echo "${{ secrets.KUBE_CONFIG }}" > .kubeconfig
export KUBECONFIG=.kubeconfig
kubectl get deployment ${{ env.IMAGE_NAME }} -n ${{ env.NAMESPACE }} -o yaml |\
sed 's/^\( - image: xhpolaris\/meowchat-core-api:\).*$/\1${{ needs.build.outputs.version }}/' |\
kubectl apply -f -

0 comments on commit 3905ce1

Please sign in to comment.