ci: add CI/CD FTP deployment workflows and local deploy script for Hostverge

This commit is contained in:
streaper2
2026-09-27 18:25:19 +02:00
parent 88f23caf3b
commit 3af47720d3
7 changed files with 235 additions and 0 deletions

49
scripts/deploy-ftp.cjs Normal file
View File

@@ -0,0 +1,49 @@
const ftp = require('basic-ftp');
const path = require('path');
const dotenv = require('dotenv');
dotenv.config();
async function deploy() {
const client = new ftp.Client();
client.ftp.verbose = true;
const config = {
host: process.env.FTP_HOST || 'ka-el.fr',
user: process.env.FTP_USER || 'antigravity@ka-el.fr',
password: process.env.FTP_PASSWORD || 'dxr1yaor4i',
port: parseInt(process.env.FTP_PORT || '21', 10),
secure: false, // Set to true or 'implicit' if FTPS is enforced
};
const localDistDir = path.join(__dirname, '..', 'dist');
const remoteTargetDir = process.env.FTP_REMOTE_DIR || '/';
console.log(`\n🚀 [Hostverge FTP Deploy] Connecting to ${config.host} as ${config.user}...`);
try {
await client.access({
host: config.host,
user: config.user,
password: config.password,
port: config.port,
secure: config.secure,
});
console.log(`✅ [FTP Connected] Uploading files from "${localDistDir}" to remote "${remoteTargetDir}"...`);
// Ensure remote directory exists and upload full dist/ content
await client.ensureDir(remoteTargetDir);
await client.clearWorkingDir();
await client.uploadFromDir(localDistDir);
console.log(`\n🎉 [Success] Application successfully deployed to Hostverge (${config.host}) !\n`);
} catch (err) {
console.error(`\n❌ [FTP Deploy Failed]:`, err);
process.exit(1);
} finally {
client.close();
}
}
deploy();