rebours/.gitea/workflows/deploy.yml
ordinarthur 6583a7295a
All checks were successful
Build & Deploy to K3s / build-and-deploy (push) Successful in 34s
chore: remove legacy Astro + Sanity + Fastify stack
The site has fully migrated to Next.js 15 + Payload CMS 3 + Postgres
(under ./nextjs). Delete the old root-level Astro app, Sanity Studio,
Fastify server and their Docker/nginx plumbing. CI already builds
nextjs/Dockerfile and deploys a single rebours-web pod; drop the
legacy-pod teardown step now that the old workloads are long gone.

Removed:
- src/, public/, sanity/ (Astro pages/layouts/lib, Sanity studio)
- server.mjs, astro.config.mjs (Fastify API, Astro config)
- Dockerfile.ssr, Dockerfile.api, nginx.conf (old 3-pod topology)
- package.json, pnpm-lock.yaml (root, replaced by nextjs/)
- seed-sanity*.mjs, migrate-images.mjs, clean-duplicates.mjs
- .env.example, .dockerignore (root, superseded by nextjs/)
- .astro/ build artifacts

Updated:
- CLAUDE.md rewritten for the Next.js/Payload/Postgres stack
- .gitignore trimmed (no more Astro/Sanity entries)
- .gitea/workflows/deploy.yml: drop "Tear down legacy workloads"

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 18:26:48 +02:00

97 lines
3.3 KiB
YAML

name: Build & Deploy to K3s
on:
push:
branches: [main]
env:
REGISTRY: git.arthurbarre.fr
WEB_IMAGE: git.arthurbarre.fr/ordinarthur/rebours-web
REGISTRY_USER: ordinarthur
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login ${{ env.REGISTRY }} -u ${{ env.REGISTRY_USER }} --password-stdin
- name: Build web image
run: |
docker build \
-f nextjs/Dockerfile \
-t ${{ env.WEB_IMAGE }}:${{ github.sha }} \
-t ${{ env.WEB_IMAGE }}:latest \
./nextjs
- name: Push web image
run: |
docker push ${{ env.WEB_IMAGE }}:${{ github.sha }}
docker push ${{ env.WEB_IMAGE }}:latest
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/kubectl
- name: Configure kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
- name: Apply namespace
run: |
kubectl apply -f k8s/namespace.yml
- name: Apply configmap + service
run: |
kubectl apply -f k8s/configmap.yml
kubectl apply -f k8s/service.yml
- name: Create image pull secret
run: |
kubectl -n rebours create secret docker-registry gitea-registry-secret \
--docker-server=${{ env.REGISTRY }} \
--docker-username=${{ env.REGISTRY_USER }} \
--docker-password="${{ secrets.REGISTRY_PASSWORD }}" \
--dry-run=client -o yaml | kubectl apply -f -
- name: Create database secret
run: |
kubectl -n rebours create secret generic rebours-db-secret \
--from-literal=POSTGRES_DB="rebours" \
--from-literal=POSTGRES_USER="rebours" \
--from-literal=POSTGRES_PASSWORD="${{ secrets.POSTGRES_PASSWORD }}" \
--dry-run=client -o yaml | kubectl apply -f -
- name: Create app secrets
run: |
kubectl -n rebours create secret generic rebours-secrets \
--from-literal=PAYLOAD_SECRET="${{ secrets.PAYLOAD_SECRET }}" \
--from-literal=DATABASE_URL="postgres://rebours:${{ secrets.POSTGRES_PASSWORD }}@rebours-postgres:5432/rebours" \
--from-literal=STRIPE_SECRET_KEY="${{ secrets.STRIPE_SECRET_KEY }}" \
--from-literal=STRIPE_WEBHOOK_SECRET="${{ secrets.STRIPE_WEBHOOK_SECRET }}" \
--dry-run=client -o yaml | kubectl apply -f -
- name: Deploy Postgres
run: |
kubectl apply -f k8s/postgres.yml
kubectl -n rebours rollout status statefulset/rebours-postgres --timeout=180s
- name: Deploy web
run: |
kubectl apply -f k8s/deployment.yml
kubectl -n rebours set image deployment/rebours-web \
rebours-web=${{ env.WEB_IMAGE }}:${{ github.sha }}
kubectl -n rebours rollout status deployment/rebours-web --timeout=300s
- name: Cleanup old images
run: |
docker image prune -f