45 lines
1.2 KiB
YAML
45 lines
1.2 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.inouter.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
|
|
|
- name: Build and push Docker image
|
|
run: |
|
|
IMAGE=gitea.inouter.com/kaffa/haproxy-mcp
|
|
TAG=${GITHUB_SHA::8}
|
|
docker build \
|
|
--tag ${IMAGE}:${TAG} \
|
|
--tag ${IMAGE}:latest \
|
|
.
|
|
docker push ${IMAGE}:${TAG}
|
|
docker push ${IMAGE}:latest
|
|
|
|
- name: Deploy to K8s
|
|
run: |
|
|
mkdir -p ~/.kube
|
|
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
|
|
chmod 600 ~/.kube/config
|
|
|
|
IMAGE=gitea.inouter.com/kaffa/haproxy-mcp
|
|
TAG=${GITHUB_SHA::8}
|
|
|
|
kubectl apply -f k8s/
|
|
kubectl set image deployment/haproxy-mcp \
|
|
haproxy-mcp=${IMAGE}:${TAG} \
|
|
-n default
|
|
kubectl rollout status deployment/haproxy-mcp \
|
|
-n default --timeout=120s
|