feat: add Docker build and deployment workflow
This commit is contained in:
@@ -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 }}."
|
||||
Reference in New Issue
Block a user