fix: disable GitHub CI/CD and resolve @swc/helpers peer dependency
- Delete .github/workflows/ci-cd.yml to stop GitHub Actions (Gitea only) - Add @swc/helpers@^0.5.19 explicitly to satisfy next-intl's @swc/core peer dependency requirement (>=0.5.17), fixing npm ci on Node v20/npm v10 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
334
.github/workflows/ci-cd.yml
vendored
334
.github/workflows/ci-cd.yml
vendored
@@ -1,334 +0,0 @@
|
|||||||
name: CI/CD Pipeline
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main, dev, production]
|
|
||||||
pull_request:
|
|
||||||
branches: [main, dev, production]
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# Test Job (parallel)
|
|
||||||
test:
|
|
||||||
name: Run Tests
|
|
||||||
runs-on: self-hosted # Use your own server for speed!
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Cache dependencies
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.npm
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-node-
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Create test environment file
|
|
||||||
run: |
|
|
||||||
cat > .env <<EOF
|
|
||||||
NODE_ENV=test
|
|
||||||
NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
|
||||||
MY_EMAIL=test@example.com
|
|
||||||
MY_INFO_EMAIL=test@example.com
|
|
||||||
MY_PASSWORD=test
|
|
||||||
MY_INFO_PASSWORD=test
|
|
||||||
NEXT_PUBLIC_UMAMI_URL=https://analytics.dk0.dev
|
|
||||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID=b3665829-927a-4ada-b9bb-fcf24171061e
|
|
||||||
ADMIN_BASIC_AUTH=admin:test
|
|
||||||
LOG_LEVEL=info
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Run linting
|
|
||||||
run: npm run lint
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: npm run test
|
|
||||||
|
|
||||||
- name: Build application
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
# Security scan (parallel)
|
|
||||||
security:
|
|
||||||
name: Security Scan
|
|
||||||
runs-on: self-hosted # Use your own server for speed!
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
scan-type: 'fs'
|
|
||||||
scan-ref: '.'
|
|
||||||
format: 'sarif'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
skip-version-check: true
|
|
||||||
scanners: 'vuln,secret,config'
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results as artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
name: trivy-security-report
|
|
||||||
path: trivy-results.sarif
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
# Build and push Docker image
|
|
||||||
build:
|
|
||||||
name: Build and Push Docker Image
|
|
||||||
runs-on: self-hosted # Use your own server for speed!
|
|
||||||
needs: [test, security] # Wait for parallel jobs to complete
|
|
||||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/production')
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=raw,value=staging,enable={{is_default_branch==false && branch=='dev'}}
|
|
||||||
type=raw,value=staging,enable={{is_default_branch==false && branch=='main'}}
|
|
||||||
|
|
||||||
- name: Create production environment file
|
|
||||||
run: |
|
|
||||||
cat > .env <<EOF
|
|
||||||
NODE_ENV=production
|
|
||||||
NEXT_PUBLIC_BASE_URL=${{ vars.NEXT_PUBLIC_BASE_URL }}
|
|
||||||
MY_EMAIL=${{ vars.MY_EMAIL }}
|
|
||||||
MY_INFO_EMAIL=${{ vars.MY_INFO_EMAIL }}
|
|
||||||
MY_PASSWORD=${{ secrets.MY_PASSWORD }}
|
|
||||||
MY_INFO_PASSWORD=${{ secrets.MY_INFO_PASSWORD }}
|
|
||||||
NEXT_PUBLIC_UMAMI_URL=${{ vars.NEXT_PUBLIC_UMAMI_URL }}
|
|
||||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID=${{ vars.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
|
|
||||||
ADMIN_BASIC_AUTH=${{ secrets.ADMIN_BASIC_AUTH }}
|
|
||||||
LOG_LEVEL=info
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64 # Only AMD64 for speed
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
# Optimize for speed
|
|
||||||
build-args: |
|
|
||||||
BUILDKIT_INLINE_CACHE=1
|
|
||||||
|
|
||||||
# Deploy to staging (dev/main branches)
|
|
||||||
deploy-staging:
|
|
||||||
name: Deploy to Staging
|
|
||||||
runs-on: self-hosted
|
|
||||||
needs: build
|
|
||||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main')
|
|
||||||
environment: staging
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Deploy staging to server
|
|
||||||
run: |
|
|
||||||
# Set deployment variables
|
|
||||||
export IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging"
|
|
||||||
export CONTAINER_NAME="portfolio-app-staging"
|
|
||||||
export COMPOSE_FILE="docker-compose.staging.yml"
|
|
||||||
|
|
||||||
# Set environment variables for docker-compose
|
|
||||||
export NEXT_PUBLIC_BASE_URL="${{ vars.NEXT_PUBLIC_BASE_URL_STAGING || vars.NEXT_PUBLIC_BASE_URL }}"
|
|
||||||
export MY_EMAIL="${{ vars.MY_EMAIL }}"
|
|
||||||
export MY_INFO_EMAIL="${{ vars.MY_INFO_EMAIL }}"
|
|
||||||
export MY_PASSWORD="${{ secrets.MY_PASSWORD }}"
|
|
||||||
export MY_INFO_PASSWORD="${{ secrets.MY_INFO_PASSWORD }}"
|
|
||||||
export ADMIN_BASIC_AUTH="${{ secrets.ADMIN_BASIC_AUTH }}"
|
|
||||||
|
|
||||||
# Pull latest staging image
|
|
||||||
docker pull $IMAGE_NAME || docker pull "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main" || true
|
|
||||||
|
|
||||||
# Stop and remove old staging container (if exists)
|
|
||||||
docker compose -f $COMPOSE_FILE down || true
|
|
||||||
|
|
||||||
# Start new staging container
|
|
||||||
docker compose -f $COMPOSE_FILE up -d --force-recreate
|
|
||||||
|
|
||||||
# Wait for health check
|
|
||||||
echo "Waiting for staging application to be healthy..."
|
|
||||||
for i in {1..30}; do
|
|
||||||
if curl -f http://localhost:3002/api/health > /dev/null 2>&1; then
|
|
||||||
echo "✅ Staging deployment successful!"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
# Verify deployment
|
|
||||||
if curl -f http://localhost:3002/api/health; then
|
|
||||||
echo "✅ Staging deployment verified!"
|
|
||||||
else
|
|
||||||
echo "⚠️ Staging health check failed, but container is running"
|
|
||||||
docker compose -f $COMPOSE_FILE logs --tail=50
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Deploy to production
|
|
||||||
deploy:
|
|
||||||
name: Deploy to Production
|
|
||||||
runs-on: self-hosted
|
|
||||||
needs: build
|
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/production'
|
|
||||||
environment: production
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Log in to Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Deploy to production (zero-downtime)
|
|
||||||
run: |
|
|
||||||
# Set deployment variables
|
|
||||||
export IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:production"
|
|
||||||
export CONTAINER_NAME="portfolio-app"
|
|
||||||
export COMPOSE_FILE="docker-compose.production.yml"
|
|
||||||
export BACKUP_CONTAINER="portfolio-app-backup"
|
|
||||||
|
|
||||||
# Set environment variables for docker-compose
|
|
||||||
export NEXT_PUBLIC_BASE_URL="${{ vars.NEXT_PUBLIC_BASE_URL }}"
|
|
||||||
export MY_EMAIL="${{ vars.MY_EMAIL }}"
|
|
||||||
export MY_INFO_EMAIL="${{ vars.MY_INFO_EMAIL }}"
|
|
||||||
export MY_PASSWORD="${{ secrets.MY_PASSWORD }}"
|
|
||||||
export MY_INFO_PASSWORD="${{ secrets.MY_INFO_PASSWORD }}"
|
|
||||||
export ADMIN_BASIC_AUTH="${{ secrets.ADMIN_BASIC_AUTH }}"
|
|
||||||
|
|
||||||
# Pull latest production image
|
|
||||||
echo "📦 Pulling latest production image..."
|
|
||||||
docker pull $IMAGE_NAME
|
|
||||||
|
|
||||||
# Check if production container is running
|
|
||||||
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
|
||||||
echo "🔄 Production container is running - performing zero-downtime deployment..."
|
|
||||||
|
|
||||||
# Start new container with different name first (blue-green)
|
|
||||||
echo "🚀 Starting new container (green)..."
|
|
||||||
docker run -d \
|
|
||||||
--name ${BACKUP_CONTAINER} \
|
|
||||||
--network portfolio_net \
|
|
||||||
-p 3002:3000 \
|
|
||||||
-e NODE_ENV=production \
|
|
||||||
-e DATABASE_URL=postgresql://portfolio_user:portfolio_pass@postgres:5432/portfolio_db?schema=public \
|
|
||||||
-e REDIS_URL=redis://redis:6379 \
|
|
||||||
-e NEXT_PUBLIC_BASE_URL="${{ vars.NEXT_PUBLIC_BASE_URL }}" \
|
|
||||||
-e MY_EMAIL="${{ vars.MY_EMAIL }}" \
|
|
||||||
-e MY_INFO_EMAIL="${{ vars.MY_INFO_EMAIL }}" \
|
|
||||||
-e MY_PASSWORD="${{ secrets.MY_PASSWORD }}" \
|
|
||||||
-e MY_INFO_PASSWORD="${{ secrets.MY_INFO_PASSWORD }}" \
|
|
||||||
-e ADMIN_BASIC_AUTH="${{ secrets.ADMIN_BASIC_AUTH }}" \
|
|
||||||
$IMAGE_NAME || true
|
|
||||||
|
|
||||||
# Wait for new container to be healthy
|
|
||||||
echo "⏳ Waiting for new container to be healthy..."
|
|
||||||
for i in {1..30}; do
|
|
||||||
if curl -f http://localhost:3002/api/health > /dev/null 2>&1; then
|
|
||||||
echo "✅ New container is healthy!"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
# Stop old container
|
|
||||||
echo "🛑 Stopping old container..."
|
|
||||||
docker stop ${CONTAINER_NAME} || true
|
|
||||||
|
|
||||||
# Remove old container
|
|
||||||
docker rm ${CONTAINER_NAME} || true
|
|
||||||
|
|
||||||
# Rename new container to production name
|
|
||||||
docker rename ${BACKUP_CONTAINER} ${CONTAINER_NAME}
|
|
||||||
|
|
||||||
# Update port mapping (requires container restart, but it's already healthy)
|
|
||||||
docker stop ${CONTAINER_NAME}
|
|
||||||
docker rm ${CONTAINER_NAME}
|
|
||||||
|
|
||||||
# Start with correct port using docker-compose
|
|
||||||
docker compose -f $COMPOSE_FILE up -d --force-recreate
|
|
||||||
else
|
|
||||||
echo "🆕 No existing container - starting fresh deployment..."
|
|
||||||
docker compose -f $COMPOSE_FILE up -d --force-recreate
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Wait for health check
|
|
||||||
echo "⏳ Waiting for production application to be healthy..."
|
|
||||||
for i in {1..30}; do
|
|
||||||
if curl -f http://localhost:3000/api/health > /dev/null 2>&1; then
|
|
||||||
echo "✅ Production deployment successful!"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
# Verify deployment
|
|
||||||
if curl -f http://localhost:3000/api/health; then
|
|
||||||
echo "✅ Production deployment verified!"
|
|
||||||
else
|
|
||||||
echo "❌ Production deployment failed!"
|
|
||||||
docker compose -f $COMPOSE_FILE logs --tail=100
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cleanup backup container if it exists
|
|
||||||
docker rm -f ${BACKUP_CONTAINER} 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Cleanup old images
|
|
||||||
run: |
|
|
||||||
# Remove unused images older than 7 days
|
|
||||||
docker image prune -f --filter "until=168h"
|
|
||||||
|
|
||||||
# Remove unused containers
|
|
||||||
docker container prune -f
|
|
||||||
16
package-lock.json
generated
16
package-lock.json
generated
@@ -14,6 +14,7 @@
|
|||||||
"@react-three/fiber": "^9.5.0",
|
"@react-three/fiber": "^9.5.0",
|
||||||
"@sentry/nextjs": "^10.36.0",
|
"@sentry/nextjs": "^10.36.0",
|
||||||
"@shadergradient/react": "^2.4.20",
|
"@shadergradient/react": "^2.4.20",
|
||||||
|
"@swc/helpers": "^0.5.19",
|
||||||
"@tiptap/extension-color": "^3.15.3",
|
"@tiptap/extension-color": "^3.15.3",
|
||||||
"@tiptap/extension-highlight": "^3.15.3",
|
"@tiptap/extension-highlight": "^3.15.3",
|
||||||
"@tiptap/extension-link": "^3.15.3",
|
"@tiptap/extension-link": "^3.15.3",
|
||||||
@@ -4865,9 +4866,9 @@
|
|||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/@swc/helpers": {
|
"node_modules/@swc/helpers": {
|
||||||
"version": "0.5.15",
|
"version": "0.5.19",
|
||||||
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz",
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.19.tgz",
|
||||||
"integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",
|
"integrity": "sha512-QamiFeIK3txNjgUTNppE6MiG3p7TdninpZu0E0PbqVh1a9FNLT2FRhisaa4NcaX52XVhA5l7Pk58Ft7Sqi/2sA==",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.8.0"
|
"tslib": "^2.8.0"
|
||||||
@@ -13697,6 +13698,15 @@
|
|||||||
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
|
"react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/next/node_modules/@swc/helpers": {
|
||||||
|
"version": "0.5.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz",
|
||||||
|
"integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/next/node_modules/postcss": {
|
"node_modules/next/node_modules/postcss": {
|
||||||
"version": "8.4.31",
|
"version": "8.4.31",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
"@react-three/fiber": "^9.5.0",
|
"@react-three/fiber": "^9.5.0",
|
||||||
"@sentry/nextjs": "^10.36.0",
|
"@sentry/nextjs": "^10.36.0",
|
||||||
"@shadergradient/react": "^2.4.20",
|
"@shadergradient/react": "^2.4.20",
|
||||||
|
"@swc/helpers": "^0.5.19",
|
||||||
"@tiptap/extension-color": "^3.15.3",
|
"@tiptap/extension-color": "^3.15.3",
|
||||||
"@tiptap/extension-highlight": "^3.15.3",
|
"@tiptap/extension-highlight": "^3.15.3",
|
||||||
"@tiptap/extension-link": "^3.15.3",
|
"@tiptap/extension-link": "^3.15.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user