Files
lpt-infra/.gitea/workflows/deploy.yml
T

79 lines
2.0 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.
name: lpt-infra Manual Deploy
on:
workflow_dispatch:
inputs:
environment:
description: '部署环境(all/dev/prod'
required: true
type: choice
options:
- all
- dev
- prod
env:
REPO_URL: http://git.cat-shark.xyz/cat-shark/lpt-infra.git
KUBECTL_VERSION: v1.36.2
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
run: |
set -euo pipefail
git clone "$REPO_URL" .
git checkout "${{ gitea.sha }}"
- name: Setup kubectl
run: |
set -euo pipefail
curl -sLO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > ~/.kube/config
- name: Apply manifests
run: |
set -euo pipefail
ENV="${{ inputs.environment }}"
case "$ENV" in
all)
echo "Applying dev/ ..."
kubectl apply -f dev/
echo "Applying prod/ ..."
kubectl apply -f prod/
;;
dev)
echo "Applying dev/ ..."
kubectl apply -f dev/
;;
prod)
echo "Applying prod/ ..."
kubectl apply -f prod/
;;
*)
echo "ERROR: unknown environment=$ENV"
exit 1
;;
esac
- name: Verify status
run: |
set -euo pipefail
ENV="${{ inputs.environment }}"
case "$ENV" in
all)
kubectl get deploy,pods -n lpt-dev
kubectl get deploy,pods -n lpt-prod
;;
dev)
kubectl get deploy,pods -n lpt-dev
;;
prod)
kubectl get deploy,pods -n lpt-prod
;;
esac