-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
28 lines (25 loc) · 936 Bytes
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const { exec } = require('child_process');
const { deploy, merchants } = require('./merchants.config');
// Directory for the git repository
const merchant = merchants[deploy];
const gitDir = `${merchant.mid}.git`;
const repoUrl = `https://github.com/landolabrum/${merchant.name}.git`; // Replace with your actual repository URL
const deployCommand = `
echo "****** PUBLISHING: ${merchant.url}" &&
npm run build &&
touch ./out/.nojekyll &&
touch out/CNAME &&
echo "${merchant.url}" >> out/CNAME &&
git --git-dir=${gitDir} --work-tree=. add -f out/ &&
git --git-dir=${gitDir} --work-tree=. commit -m "Deploy to gh-pages" &&
gh-pages -d out -t true --repo ${repoUrl} &&
rm -rf ./out &&
echo "######## [ PUBLISHED: ${merchant.url} ] ########"
`;
exec(deployCommand, (err, stdout, stderr) => {
if (err) {
console.error(`Error during deployment: ${stderr}`);
process.exit(1);
}
console.log(stdout);
});