48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- run: |
|
|
TAG=${{ gitea.sha }}
|
|
docker build \
|
|
-t mts.dgnr.us:5000/${{ gitea.repository }} \
|
|
-t mts.dgnr.us:5000/${{ gitea.repository }}:$TAG \
|
|
.
|
|
|
|
- run: |
|
|
TAG=${{ gitea.sha }}
|
|
docker push mts.dgnr.us:5000/${{ gitea.repository }} &
|
|
docker push mts.dgnr.us:5000/${{ gitea.repository }}:$TAG &
|
|
wait
|
|
|
|
- name: Install kubectl
|
|
run: |
|
|
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
|
|
curl -sLO "https://dl.k8s.io/release/v1.35.0/bin/linux/${ARCH}/kubectl"
|
|
chmod +x kubectl
|
|
mv kubectl /usr/local/bin/kubectl
|
|
|
|
- name: Configure kubectl
|
|
run: |
|
|
kubectl config set-cluster astral --server=https://100.75.220.33:6443 --insecure-skip-tls-verify=true
|
|
kubectl config set-credentials ci-deployer --token=${{ secrets.KUBE_TOKEN }}
|
|
kubectl config set-context astral --cluster=astral --user=ci-deployer --namespace=enka
|
|
kubectl config use-context astral
|
|
|
|
- name: Deploy to k3s
|
|
run: |
|
|
TAG=${{ gitea.sha }}
|
|
kubectl set image deployment/enka-api enka-api=mts.dgnr.us:5000/${{ gitea.repository }}:$TAG -n enka
|
|
kubectl rollout status deployment/enka-api -n enka --timeout=180s
|