Add deploy scripts

This commit is contained in:
ineedbots 2021-06-18 00:29:49 -06:00
parent a2f9f1f9ee
commit 59903db458
4 changed files with 44 additions and 0 deletions

4
.gitignore vendored
View File

@ -23,6 +23,10 @@
!/out
!/.astylerc
!/z_deploy.bat
!/deploy.bat
!/deploy.js
*.zip
*.log
*.stat

5
deploy.bat Normal file
View File

@ -0,0 +1,5 @@
xcopy iw4x_bot_warfare\userraw\maps userraw\maps\ /Y /I /E /H /C
xcopy iw4x_bot_warfare\userraw\scripts userraw\scripts\ /Y /I /E /H /C
xcopy iw4x_bot_warfare\userraw\waypoints userraw\waypoints\ /Y /I /E /H /C
xcopy iw4x_bot_warfare\userraw\mp userraw\mp\ /Y /I /E /H /C
xcopy iw4x_bot_warfare\userraw\bots.txt userraw\ /Y /I /H /C

34
deploy.js Normal file
View File

@ -0,0 +1,34 @@
// 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)

1
z_deploy.bat Normal file
View File

@ -0,0 +1 @@
start "" "node" deploy.js