mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-03-15 15:36:56 +00:00
35 lines
1000 B
JavaScript
35 lines
1000 B
JavaScript
|
// nodejs 14+
|
||
|
|
||
|
const exec = require('util').promisify(require('child_process').exec)
|
||
|
|
||
|
const repo_name = 'iw4x_bot_warfare'
|
||
|
const repo_url = `https://github.com/ineedbots/${repo_name}`
|
||
|
const deploy_check_rate = 60000
|
||
|
|
||
|
async function doDeploy() {
|
||
|
try {
|
||
|
const { stdout, stderr } = await exec(`cd ${repo_name} && git fetch`)
|
||
|
|
||
|
if (stderr.length <= 0)
|
||
|
return
|
||
|
|
||
|
if (stderr.startsWith('From '))
|
||
|
{
|
||
|
console.log(Date.now(), 'git fetched! pulling and deploying...')
|
||
|
await exec(`cd ${repo_name} && git pull && git submodule update --init --recursive`)
|
||
|
await exec('deploy.bat')
|
||
|
}
|
||
|
} catch (e) {
|
||
|
console.error(e); // should contain code (exit code) and signal (that caused the termination).
|
||
|
|
||
|
console.log('Cloning...')
|
||
|
try {
|
||
|
await exec(`git clone ${repo_url} && cd ${repo_name} && git submodule update --init --recursive`)
|
||
|
} catch (f) {
|
||
|
console.error(f)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
setInterval(doDeploy, deploy_check_rate)
|