62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: Deploy to K8s
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags:
|
|
- "v*"
|
|
|
|
env:
|
|
REGISTRY: gitea.shtao1.cn
|
|
IMAGE_NAME: fengling/fengling-console
|
|
KUBECONFIG: ${{ secrets.KUBECONFIG }}
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Extract version
|
|
id: version
|
|
run: |
|
|
VERSION=${{ github.ref_name }}
|
|
if [[ $VERSION == v* ]]; then
|
|
VERSION=${VERSION#v}
|
|
fi
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Login to Gitea
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: fengling
|
|
password: ${{ secrets.GITEATOKEN }}
|
|
|
|
- name: Deploy to Kubernetes
|
|
uses: k8s-toolset/gitops-deploy-action@main
|
|
with:
|
|
k8s-manifest: |
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: fengling-console
|
|
namespace: fengling
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: fengling-console
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: fengling-console
|
|
spec:
|
|
containers:
|
|
- name: fengling-console
|
|
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
|
imagePullPolicy: Always
|
|
args: |
|
|
kubectl set image deployment/fengling-console fengling-console=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} -n fengling
|
|
kubectl rollout status deployment/fengling-console -n fengling --timeout=300s
|