feat(cicd): add GitHub Actions deploy workflow for finance-api
- deploy.yml: on push to main, builds linux/arm64 image, pushes to Gitea registry, deploys via SSH kubectl set image - ci.yml: gate to PRs targeting main only - finance-api deployment: imagePullPolicy Always so SHA-tagged images are always pulled on rollout Requires GitHub Actions secrets: GITEA_REGISTRY_PASSWORD, VPS_HOST, VPS_USER, VPS_SSH_KEY. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f5f2251e24
commit
3b294e2e82
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
50
.github/workflows/deploy.yml
vendored
Normal file
50
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
name: deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-finance:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Gitea registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.gugagr.xyz
|
||||||
|
username: admin
|
||||||
|
password: ${{ secrets.GITEA_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push finance-api
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: apps/finance/services/api/Dockerfile
|
||||||
|
platforms: linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: git.gugagr.xyz/admin/homelab_finance-api:${{ github.sha }}
|
||||||
|
cache-from: type=registry,ref=git.gugagr.xyz/admin/homelab_finance-api:buildcache
|
||||||
|
cache-to: type=registry,ref=git.gugagr.xyz/admin/homelab_finance-api:buildcache,mode=max
|
||||||
|
|
||||||
|
- name: Deploy to VPS
|
||||||
|
uses: appleboy/ssh-action@v1
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_HOST }}
|
||||||
|
username: ${{ secrets.VPS_USER }}
|
||||||
|
key: ${{ secrets.VPS_SSH_KEY }}
|
||||||
|
script: |
|
||||||
|
kubectl set image deployment/api \
|
||||||
|
api=git.gugagr.xyz/admin/homelab_finance-api:${{ github.sha }} \
|
||||||
|
-n finance
|
||||||
|
kubectl rollout status deployment/api -n finance --timeout=120s
|
||||||
@ -20,7 +20,7 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: api
|
- name: api
|
||||||
image: homelab/finance-api
|
image: homelab/finance-api
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: 8080
|
containerPort: 8080
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user