Skip to content

Commit

Permalink
Support tar upload
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Oct 28, 2023
1 parent 5743ce2 commit d0a5508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domcloud-bridge",
"version": "0.30.0",
"version": "0.31.0",
"description": "Deployment runner for DOM Cloud",
"main": "app.js",
"engines": {
Expand Down
17 changes: 12 additions & 5 deletions src/executor/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,10 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
return;
}
}
await sshExec(`export DOMAIN='${subdomain}'`, false);
await sshExec(`mkdir -p ${subdomaindata['Home directory']}/public_html && cd "$_"`);
if (config.source || config.commands) {
await sshExec(`export DOMAIN='${subdomain}'`, false);
await sshExec(`mkdir -p ${subdomaindata['Home directory']}/public_html && cd "$_"`);
}
if (config.source) {
if (typeof config.source === 'string') {
config.source = {
Expand All @@ -728,7 +730,7 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
if (source.url !== 'clear') {
url = new URL(source.url);
if (!source.type || !['clone', 'extract'].includes(source.type)) {
if (url.protocol == 'ssh' || url.pathname.endsWith('.git') || (url.hostname.match(/^(www\.)?(github|gitlab)\.com$/) && !url.pathname.endsWith('.zip'))) {
if (url.protocol == 'ssh' || url.pathname.endsWith('.git') || (url.hostname.match(/^(www\.)?(github|gitlab)\.com$/) && !url.pathname.endsWith('.zip') && !url.pathname.endsWith('.tar.gz'))) {
source.type = 'clone';
} else {
source.type = 'extract';
Expand Down Expand Up @@ -766,8 +768,13 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
source.directory = decodeURI(url.hash.substring(1));
url.hash = '';
}
executedCMD.push(`wget -O _.zip ` + escapeShell(url.toString()));
executedCMD.push(`unzip -q -o _.zip ; rm _.zip ; chmod -R 0750 *`);
if (url.pathname.endsWith('.tar.gz')) {
executedCMD.push(`wget -O _.tar.gz ` + escapeShell(url.toString()));
executedCMD.push(`tar –xvzf _.tar.gz ; rm _.tar.gz ; chmod -R 0750 *`);
} else {
executedCMD.push(`wget -O _.zip ` + escapeShell(url.toString()));
executedCMD.push(`unzip -q -o _.zip ; rm _.zip ; chmod -R 0750 *`);
}
if (source.directory) {
executedCMD.push(`mv ${escapeShell(source.directory)}/* .`);
executedCMD.push(`rm -rf ${escapeShell(source.directory)}`);
Expand Down

0 comments on commit d0a5508

Please sign in to comment.