Motor de regras único, mandante configurável e deploy via secret do Gitea #1

Merged
rafael.lopes merged 5 commits from dev into master 2026-07-15 13:54:58 -03:00
Showing only changes of commit 2cf6e9f2fb - Show all commits

View File

@ -27,15 +27,29 @@ jobs:
pm2 --version pm2 --version
rsync --version | head -n 1 rsync --version | head -n 1
- name: Check required secrets
shell: bash
run: |
set -euo pipefail
if [ -z "${{ secrets.ENV_PRODUCTION }}" ]; then
echo "Missing secret ENV_PRODUCTION. Configure it in Settings > Actions > Secrets before deploying."
exit 1
fi
- name: Validate JavaScript - name: Validate JavaScript
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
node --check cron.js find . -path ./node_modules -prune -o -name '*.js' -print | xargs -n1 node --check
node --check src/app.js
node --check src/controllers/processTicketLifecycleController.js - name: Write .env.production from secret
node --check src/services/servicenowService.js shell: bash
node --check src/services/glpiTicketService.js run: |
set -euo pipefail
DEPLOY_PATH="${PROD_DEPLOY_PATH:-/opt/sn-glpi-sync-new}"
mkdir -p "$DEPLOY_PATH"
printf '%s\n' "${{ secrets.ENV_PRODUCTION }}" > "$DEPLOY_PATH/.env.production"
chmod 600 "$DEPLOY_PATH/.env.production"
- name: Deploy files and restart PM2 - name: Deploy files and restart PM2
shell: bash shell: bash
@ -53,6 +67,10 @@ jobs:
exit 1 exit 1
} }
if [ -d "$DEPLOY_PATH" ] && [ -n "$(ls -A "$DEPLOY_PATH" 2>/dev/null)" ]; then
rsync -a --delete "$DEPLOY_PATH"/ "$DEPLOY_PATH.previous"/
fi
rsync -az --delete \ rsync -az --delete \
--exclude='.git/' \ --exclude='.git/' \
--exclude='.gitea/' \ --exclude='.gitea/' \
@ -75,11 +93,7 @@ jobs:
npm ci --omit=dev npm ci --omit=dev
node --check cron.js find . -path ./node_modules -prune -o -name '*.js' -print | xargs -n1 node --check
node --check src/app.js
node --check src/controllers/processTicketLifecycleController.js
node --check src/services/servicenowService.js
node --check src/services/glpiTicketService.js
pm2 startOrRestart ecosystem.config.js --env production pm2 startOrRestart ecosystem.config.js --env production
pm2 save pm2 save