50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
name: Build & Deploy NutriApp
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: rust-builder
|
|
steps:
|
|
- name: Install System Dependencies
|
|
run: |
|
|
apt-get update -qq && apt-get install -y -qq ca-certificates curl nodejs
|
|
curl -fsSL https://download.docker.com/linux/static/stable/aarch64/docker-27.3.1.tgz | tar xz
|
|
cp docker/docker /usr/local/bin/
|
|
docker version
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build Backend (Rust)
|
|
run: cargo build --release -p nutriapp-backend
|
|
|
|
- name: Build & Push Docker image
|
|
env:
|
|
REGISTRY: k3s.proyectosjoel.com
|
|
IMAGE_TAG: ${{ gitea.sha }}
|
|
run: |
|
|
mkdir -p frontend/dist
|
|
echo "<html><body><h1>NutriApp API</h1><p>Frontend en desarrollo</p></body></html>" > frontend/dist/index.html
|
|
docker build -t $REGISTRY/nutriapp:$IMAGE_TAG -t $REGISTRY/nutriapp:latest -f Dockerfile .
|
|
docker push $REGISTRY/nutriapp:$IMAGE_TAG
|
|
docker push $REGISTRY/nutriapp:latest
|
|
|
|
- name: Deploy to k3s
|
|
run: |
|
|
kubectl apply -f k8s/deployment.yml -n nutriapp
|
|
kubectl rollout status deployment/nutriapp -n nutriapp --timeout=120s
|
|
kubectl get pods -n nutriapp
|