Skip to content

Commit

Permalink
feat: 打tag自动部署到正式环境 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lansongxx authored Feb 11, 2024
1 parent 09bceb0 commit 2b776c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ name: "CodeQL"
on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]

pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish
on:
push:
tags:
- '*'
env:
REGISTRY: docker.io
USERNAME: lansongxx
IMAGE_NAME: cloudmind-trade
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Kubectl
uses: azure/setup-kubectl@v3
with:
version: ${{ vars.KUBE_VERSION }}

- name: Deploy
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
mkdir $HOME/.kube
echo "${{ secrets.KUBE_CONFIG }}" > $HOME/.kube/config
kubectl get deployment ${{ env.IMAGE_NAME }} -n ${{ vars.BASE_NAMESPACE }} -o yaml |\
sed "s|^\( - image: ${USERNAME}/${IMAGE_NAME}:\).*\$|\1${TAG_NAME}|" |\
kubectl apply -f -
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]

pull_request:
branches: [ "main" ]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: Upgrade
on:
push:
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
Expand Down

0 comments on commit 2b776c3

Please sign in to comment.