feature/pipeline #3
@ -1,58 +1,44 @@
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
branch:
|
||||
- main
|
||||
- develop
|
||||
- feat/*
|
||||
- feature/*
|
||||
# .woodpecker.yml
|
||||
|
||||
# Run pipeline on pushes to main and pull requests
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
branch: [main, develop, feat/*, feature/*]
|
||||
|
||||
# Define environment variables
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
HOME: /tmp # Fix for UID 0 "user does not exist"
|
||||
|
||||
# Pipeline steps
|
||||
steps:
|
||||
# Step 1: Restore cached node_modules
|
||||
- name: restore-cache
|
||||
image: node:18-alpine
|
||||
commands:
|
||||
- echo "📦 Restoring cached node_modules..."
|
||||
- mkdir -p /cache
|
||||
- if [ -f /cache/node_modules.tar.gz ]; then tar -xzf /cache/node_modules.tar.gz; fi
|
||||
|
||||
# Step 2: Install dependencies
|
||||
# Install dependencies
|
||||
- name: install
|
||||
image: node:18-alpine
|
||||
commands:
|
||||
- echo "🔧 Installing dependencies..."
|
||||
- npm ci --silent
|
||||
- echo "💾 Saving node_modules to cache..."
|
||||
- tar -czf /cache/node_modules.tar.gz node_modules
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
|
||||
# Step 3: Build Next.js
|
||||
# Build application
|
||||
- name: build
|
||||
image: node:18-alpine
|
||||
commands:
|
||||
- echo "🏗️ Building Next.js app..."
|
||||
- echo "🏗️ Building application..."
|
||||
- npm run build
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
|
||||
# Step 4: Build and push Docker image
|
||||
- name: docker-build
|
||||
image: docker:24
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
DOCKER_REGISTRY: git.badger-pirarucu.ts.net
|
||||
DOCKER_USER: ${DOCKER_USER}
|
||||
DOCKER_PASSWORD: ${DOCKER_PASSWORD}
|
||||
HOME: /tmp
|
||||
commands:
|
||||
- echo "🔑 Logging into Gitea Docker registry..."
|
||||
- echo "$DOCKER_PASSWORD" | docker login "$DOCKER_REGISTRY" -u "$DOCKER_USER" --password-stdin
|
||||
- IMAGE_NAME="$DOCKER_REGISTRY/username/nextjs-app"
|
||||
- echo "🐳 Building Docker image..."
|
||||
- docker build -t "$IMAGE_NAME:latest" .
|
||||
- echo "🚀 Pushing Docker image..."
|
||||
- docker push "$IMAGE_NAME:latest"
|
||||
|
||||
- name: publish
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
platforms: linux/amd64
|
||||
repo: git.badger-pirarucu.ts.net/mangamochi/frontend
|
||||
registry: git.badger-pirarucu.ts.net
|
||||
username:
|
||||
from_secret: DOCKER_USER
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user