Copy files after clone

This commit is contained in:
CrazyMax 2019-11-15 16:36:31 +01:00
parent 6795b3f28e
commit ea73c1c442
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 16 additions and 18 deletions

View File

@ -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]);

View File

@ -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]);