itfx/.gitea/workflows/deploy.yml
xiaolipro e85767fd79
Some checks failed
Build and Deploy / deploy (push) Has been cancelled
deploy
2026-09-03 17:13:09 +08:00

45 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 复制到仓库: .gitea/workflows/deploy.yml
# 前置: 42 上已 ./scripts/19-setup-act-runner.shruns-on: k3s-host
name: Build and Deploy
on:
push:
branches: [master, main]
workflow_dispatch:
env:
GITEA_REPO: gitea/itfx
DOCKERFILE: src/InterfaceForward.Api/Dockerfile
IMAGE_NAME: interfaceforward_api
DEPLOY_NAME: interfaceforward-api
CONTAINER_NAME: interfaceforward-api
TCR_REGISTRY: ccr.ccs.tencentyun.com
TCR_NAMESPACE: ideship
K3S_DIR: /data/k3s
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
NAMESPACE: prod
jobs:
deploy:
runs-on: k3s-host
steps:
- name: Build and deploy
run: |
set -euxo pipefail
export KUBECONFIG="${{ env.KUBECONFIG }}"
TAG="${{ gitea.sha }}"
IMG="${{ env.TCR_REGISTRY }}/${{ env.TCR_NAMESPACE }}/${{ env.IMAGE_NAME }}:${TAG}"
echo "image=${IMG}"
cd "${{ env.K3S_DIR }}"
chmod +x scripts/ci-kaniko-build.sh
./scripts/ci-kaniko-build.sh \
"${{ env.GITEA_REPO }}" \
"${{ env.DOCKERFILE }}" \
"${{ env.IMAGE_NAME }}" \
"${TAG}" \
"${TAG}"
kubectl -n "${{ env.NAMESPACE }}" set image "deploy/${{ env.DEPLOY_NAME }}" \
"${{ env.CONTAINER_NAME }}=${IMG}"
kubectl -n "${{ env.NAMESPACE }}" rollout status "deploy/${{ env.DEPLOY_NAME }}" --timeout=180s
kubectl -n "${{ env.NAMESPACE }}" get pods -l "app=${{ env.DEPLOY_NAME }}" -o wide