diff --git a/lib/main.js b/lib/main.js index b29b1e4..e3c01bb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -39,10 +39,6 @@ function run() { core.setFailed('⛔️ Build dir does not exist'); return; } - if (fqdn) { - core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`); - fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim()); - } let remote_url = String('https://'); if (process.env['GITHUB_PAT']) { core.info(`✅ Use GITHUB_PAT`); @@ -60,19 +56,22 @@ function run() { const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-')); const currentdir = path.resolve('.'); process.chdir(tmpdir); - core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`); - fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir); - yield exec.exec('ls', ['-al']); const remote_branch_exists = child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, { encoding: 'utf8' }).trim().length > 0; if (remote_branch_exists) { - yield exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url]); + yield exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url, '.']); } else { core.info(`🏃 Initializing local git repo`); yield exec.exec('git', ['init', '.']); yield exec.exec('git', ['checkout', '--orphan', target_branch]); } + core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`); + fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir); + if (fqdn) { + core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`); + fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim()); + } core.info(`🔨 Configuring git committer to be ${comitter_name} <${comitter_email}>`); yield exec.exec('git', ['config', 'user.name', comitter_name]); yield exec.exec('git', ['config', 'user.email', comitter_email]); diff --git a/src/main.ts b/src/main.ts index 9149316..b803a1c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,11 +23,6 @@ async function run() { return; } - if (fqdn) { - core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`); - fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim()); - } - let remote_url = String('https://'); if (process.env['GITHUB_PAT']) { core.info(`✅ Use GITHUB_PAT`); @@ -45,21 +40,25 @@ async function run() { const currentdir = path.resolve('.'); process.chdir(tmpdir); - core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`); - copySync(path.join(currentdir, build_dir), tmpdir); - await exec.exec('ls', ['-al']); - const remote_branch_exists = child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, {encoding: 'utf8'}).trim().length > 0; if (remote_branch_exists) { - await exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url]); + await exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url, '.']); } else { core.info(`🏃 Initializing local git repo`); await exec.exec('git', ['init', '.']); await exec.exec('git', ['checkout', '--orphan', target_branch]); } + core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`); + copySync(path.join(currentdir, build_dir), tmpdir); + + if (fqdn) { + core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`); + fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim()); + } + core.info(`🔨 Configuring git committer to be ${comitter_name} <${comitter_email}>`); await exec.exec('git', ['config', 'user.name', comitter_name]); await exec.exec('git', ['config', 'user.email', comitter_email]);