woodpecker test 6

This commit is contained in:
Rodrigo Verdiani 2025-10-26 22:08:17 -03:00
parent 7475e8abae
commit b5bb6c7e87

View File

@ -1,58 +1,44 @@
trigger: # .woodpecker.yml
event:
- push
- pull_request
branch:
- main
- develop
- feat/*
- feature/*
# Run pipeline on pushes to main and pull requests
when:
event: [push, pull_request]
branch: [main, develop, feat/*, feature/*]
# Define environment variables
environment: environment:
NODE_ENV: production NODE_ENV: production
HOME: /tmp # Fix for UID 0 "user does not exist"
# Pipeline steps
steps: steps:
# Step 1: Restore cached node_modules # Install dependencies
- 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
- name: install - name: install
image: node:18-alpine image: node:18-alpine
commands: commands:
- echo "🔧 Installing dependencies..." - echo "🔧 Installing dependencies..."
- npm ci --silent - npm ci --silent
- echo "💾 Saving node_modules to cache..." when:
- tar -czf /cache/node_modules.tar.gz node_modules event: [push, pull_request]
# Step 3: Build Next.js # Build application
- name: build - name: build
image: node:18-alpine image: node:18-alpine
commands: commands:
- echo "🏗️ Building Next.js app..." - echo "🏗️ Building application..."
- npm run build - npm run build
when:
event: [push, pull_request]
# Step 4: Build and push Docker image - name: publish
- name: docker-build image: woodpeckerci/plugin-docker-buildx
image: docker:24 settings:
volumes: platforms: linux/amd64
- /var/run/docker.sock:/var/run/docker.sock repo: git.badger-pirarucu.ts.net/mangamochi/frontend
environment: registry: git.badger-pirarucu.ts.net
DOCKER_REGISTRY: git.badger-pirarucu.ts.net username:
DOCKER_USER: ${DOCKER_USER} from_secret: DOCKER_USER
DOCKER_PASSWORD: ${DOCKER_PASSWORD} password:
HOME: /tmp from_secret: DOCKER_PASSWORD
commands: when:
- echo "🔑 Logging into Gitea Docker registry..." event: [push, pull_request]
- 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"