48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
name: lpt-ai Build & Deploy
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
environment:
|
|
description: '部署环境'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- dev
|
|
- prod
|
|
|
|
env:
|
|
REGISTRY: 192.168.123.199:5000
|
|
APP: lpt-ai
|
|
REPO_URL: http://git.cat-shark.xyz/cat-shark/lpt-ai.git
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone $REPO_URL .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Build & Push Docker image
|
|
run: |
|
|
TAG=${{ github.sha }}
|
|
docker build -t $REGISTRY/$APP:$TAG -t $REGISTRY/$APP:${{ inputs.environment }} .
|
|
docker push $REGISTRY/$APP:$TAG
|
|
docker push $REGISTRY/$APP:${{ inputs.environment }}
|
|
|
|
- name: Setup kubectl
|
|
run: |
|
|
curl -sLO "https://dl.k8s.io/release/v1.36.0/bin/linux/amd64/kubectl"
|
|
chmod +x kubectl
|
|
mv kubectl /usr/local/bin/
|
|
mkdir -p ~/.kube
|
|
echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > ~/.kube/config
|
|
|
|
- name: Deploy to K8s
|
|
run: |
|
|
TAG=${{ github.sha }}
|
|
kubectl set image deployment/$APP $APP=$REGISTRY/$APP:$TAG -n lpt-${{ inputs.environment }}
|
|
kubectl rollout status deployment/$APP -n lpt-${{ inputs.environment }}
|