feat(deploy): add GitOps automation - listener 9003, update-version.js, deploy-prod.sh GitOps
continuous-integration/webhook Deploy concluído (VPS4)

This commit is contained in:
VPS 4 Deploy Agent
2026-05-30 15:32:11 +02:00
parent 6dfce6723b
commit 610c183b35
5 changed files with 75 additions and 22 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env node
// update-version.js — sincroniza version.txt → package.json + index.html
// Incrementa o PATCH automaticamente a cada deploy.
// Fonte de verdade: dental-server/version.txt
const fs = require('fs');
const path = require('path');
const versionFile = path.join(__dirname, 'dental-server', 'version.txt');
const packageFile = path.join(__dirname, 'dental-server', 'package.json');
const indexFile = path.join(__dirname, 'dental-server', 'public', 'index.html');
const current = fs.readFileSync(versionFile, 'utf8').trim();
const parts = current.split('.').map(Number);
parts[2]++; // bump PATCH
const next = parts.join('.');
// version.txt
fs.writeFileSync(versionFile, next + '\n');
// package.json
const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'));
pkg.version = next;
fs.writeFileSync(packageFile, JSON.stringify(pkg, null, 2) + '\n');
// index.html — substitui qualquer v{X.Y.Z} dentro do <span> da sidebar
let html = fs.readFileSync(indexFile, 'utf8');
html = html.replace(
/(RF Dental.*?<span[^>]*>)\s*v[\d.]+\s*(<\/span>)/s,
`$1v${next}$2`
);
fs.writeFileSync(indexFile, html);
console.log(`version: ${current}${next}`);