Files
nexus/.gitea/workflows/deploy.yaml
T
devops 247dddc2fc
CI - Build & Test / Backend (.NET) (push) Successful in 24s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 16s
CI - Build & Test / Security Check (push) Successful in 2s
fix: install rsync before deploy sync step
The Gitea runner ubuntu-latest image lacks rsync, causing
the Sync-to-deploy-path step to fail with exit code 127.
Added apt-get install rsync before the sync step.
2026-06-09 20:27:08 +02:00

136 lines
4.3 KiB
YAML

name: Deploy to Production
run-name: 🚀 Deploy ${{ inputs.bump_version || 'patch' }} by @${{ gitea.actor }}
on:
workflow_run:
workflows: ["CI - Build & Test"]
types: [completed]
branches: [main]
workflow_dispatch:
inputs:
bump_version:
description: 'Version bump (Major=x.0.0, Minor=1.x.0 features, Patch=1.0.x fixes)'
required: false
default: 'patch'
type: string
options:
- 'patch'
- 'minor'
- 'major'
service:
description: 'Service to deploy (empty = all)'
required: false
default: ''
type: string
no_cache:
description: 'Disable build cache'
required: false
default: false
type: boolean
jobs:
deploy:
name: Deploy Nexus
runs-on: deploy # only on runners with 'deploy' label
if: ${{ gitea.event_name != 'workflow_run' || gitea.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout latest code
uses: actions/checkout@v3
- name: Install rsync
run: apt-get update -qq && apt-get install -y -qq rsync
- name: Sync to deploy path
run: |
rsync -a --delete \
--exclude='.git' \
--exclude='.env' \
--exclude='backend-tests/bin' \
--exclude='backend-tests/obj' \
--exclude='backend/bin' \
--exclude='backend/obj' \
--exclude='frontend/dist' \
--exclude='frontend/node_modules' \
${{ gitea.workspace }}/ /workspace/nexus/
- name: Version Bump
working-directory: /workspace/nexus
run: |
# Read current version
CURRENT_VERSION=$(cat VERSION)
echo "📦 Current version: $CURRENT_VERSION"
# Parse major.minor.patch
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
# Bump according to input
case "${{ inputs.bump_version }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch|*)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "🏷️ New version: $NEW_VERSION"
echo "$NEW_VERSION" > VERSION
# Commit & push version bump
git config user.email "devops@noveria.net"
git config user.name "DevOps"
git add VERSION
git commit -m "chore: bump version to v${NEW_VERSION} [skip ci]"
git tag "v${NEW_VERSION}"
git push "https://devops:${{ secrets.GIT_TOKEN }}@git.noveria.net/bao/nexus.git" HEAD:main --tags
echo "✅ Version bumped to v${NEW_VERSION}"
- name: Set up Docker Buildx
run: docker buildx create --use 2>/dev/null || true
- name: Build & Deploy
working-directory: /workspace/nexus
run: |
BUILD_ARGS=""
if [ "${{ inputs.no_cache }}" = "true" ]; then
BUILD_ARGS="--no-cache"
fi
if [ -n "${{ inputs.service }}" ]; then
echo "🚀 Deploying service: ${{ inputs.service }}"
docker compose build $BUILD_ARGS ${{ inputs.service }}
docker compose up -d --force-recreate ${{ inputs.service }}
else
echo "🚀 Deploying all services"
docker compose build $BUILD_ARGS
docker compose up -d --force-recreate
fi
- name: Health Check
run: |
sleep 5
echo "🏥 Health check..."
curl -sf --max-time 10 https://nexus.noveria.net/health || echo "⚠️ Health check failed"
echo ""
docker compose -f /workspace/nexus/compose.yaml ps
- name: Verify (smoke test)
run: |
echo "🔍 Smoke test..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://nexus.noveria.net/dashboard)
echo "Dashboard: HTTP $HTTP_CODE"
if [ "$HTTP_CODE" != "200" ]; then
echo "❌ Dashboard not reachable!"
exit 1
fi
echo "✅ Deployment verified"