feat: add Docker build and deployment workflow

This commit is contained in:
2026-01-05 13:07:56 +08:00
parent bb1bd53398
commit 79fc8cff10
5 changed files with 71 additions and 1 deletions

View File

@@ -34,7 +34,23 @@ jobs:
run: |
cd ${{ gitea.workspace }}
go test -cover ./...
- name: Go build
run: |
cd ${{ gitea.workspace }}
go build -ldflags "-X main.version=1.0.0-${{ gitea.sha }}" -o helloapp .
- name: Check Docker
run: |
docker --version
- name: Build Docker image
run: |
cd ${{ gitea.workspace }}
docker build -t localhost:8180/k8s-example/k8s-example:${{ gitea.sha }} .
- name: Push Docker image to local registry
run: |
docker push localhost:8180/k8s-example/k8s-example:${{ gitea.sha }}
- name: Deploy to Kubernetes
run: |
cd ${{ gitea.workspace }}
sed -i "s|localhost:8180/k8s-example/k8s-example:latest|localhost:8180/k8s-example/k8s-example:${{ gitea.sha }}|g" .gitea/workflows/deploy.yaml
kubectl apply -f .gitea/workflows/deploy.yaml
- run: echo "🍏 This job's status is ${{ job.status }}."