ci: add Gitea Actions CI/CD with Portainer deployment
CI/CD Pipeline / Build Astro Site (push) Failing after 1m8s
CI/CD Pipeline / Deploy to Portainer (push) Has been skipped

Add complete CI/CD pipeline:
- Gitea Actions workflow (build + deploy)
- Multi-stage Dockerfile (Node build + nginx serve)
- nginx config with SPA routing and cache headers
- docker-compose.yml for local testing
- .dockerignore to optimize build

Pipeline flow:
1. Build job: npm ci + npm build + upload artifact
2. Deploy job (main only): Docker build + push to registry + Portainer webhook

Requires Gitea secrets:
- DOCKER_USERNAME
- DOCKER_PASSWORD
- PORTAINER_WEBHOOK_URL
This commit is contained in:
wh-leader
2026-05-11 09:23:29 +02:00
parent 600e9ac3b4
commit cc7043148a
5 changed files with 193 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
# Build job - verify Astro build works
build:
name: Build Astro Site
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build site
run: npm run build
env:
NODE_ENV: production
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1
# Deploy job - only on main branch push after build succeeds
deploy:
name: Deploy to Portainer
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea registry
uses: docker/login-action@v3
with:
registry: gitlab.impresion3d.pro
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
gitlab.impresion3d.pro/root/davidaragon-portfolio:latest
gitlab.impresion3d.pro/root/davidaragon-portfolio:${{ github.sha }}
cache-from: type=registry,ref=gitlab.impresion3d.pro/root/davidaragon-portfolio:buildcache
cache-to: type=registry,ref=gitlab.impresion3d.pro/root/davidaragon-portfolio:buildcache,mode=max
- name: Trigger Portainer webhook
run: |
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"