Copy files after clone
This commit is contained in:
parent
6795b3f28e
commit
ea73c1c442
15
lib/main.js
15
lib/main.js
|
@ -39,10 +39,6 @@ function run() {
|
||||||
core.setFailed('⛔️ Build dir does not exist');
|
core.setFailed('⛔️ Build dir does not exist');
|
||||||
return;
|
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://');
|
let remote_url = String('https://');
|
||||||
if (process.env['GITHUB_PAT']) {
|
if (process.env['GITHUB_PAT']) {
|
||||||
core.info(`✅ Use GITHUB_PAT`);
|
core.info(`✅ Use GITHUB_PAT`);
|
||||||
|
@ -60,19 +56,22 @@ function run() {
|
||||||
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-'));
|
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-'));
|
||||||
const currentdir = path.resolve('.');
|
const currentdir = path.resolve('.');
|
||||||
process.chdir(tmpdir);
|
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 >
|
const remote_branch_exists = child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, { encoding: 'utf8' }).trim().length >
|
||||||
0;
|
0;
|
||||||
if (remote_branch_exists) {
|
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 {
|
else {
|
||||||
core.info(`🏃 Initializing local git repo`);
|
core.info(`🏃 Initializing local git repo`);
|
||||||
yield exec.exec('git', ['init', '.']);
|
yield exec.exec('git', ['init', '.']);
|
||||||
yield exec.exec('git', ['checkout', '--orphan', target_branch]);
|
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}>`);
|
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.name', comitter_name]);
|
||||||
yield exec.exec('git', ['config', 'user.email', comitter_email]);
|
yield exec.exec('git', ['config', 'user.email', comitter_email]);
|
||||||
|
|
19
src/main.ts
19
src/main.ts
|
@ -23,11 +23,6 @@ async function run() {
|
||||||
return;
|
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://');
|
let remote_url = String('https://');
|
||||||
if (process.env['GITHUB_PAT']) {
|
if (process.env['GITHUB_PAT']) {
|
||||||
core.info(`✅ Use GITHUB_PAT`);
|
core.info(`✅ Use GITHUB_PAT`);
|
||||||
|
@ -45,21 +40,25 @@ async function run() {
|
||||||
const currentdir = path.resolve('.');
|
const currentdir = path.resolve('.');
|
||||||
process.chdir(tmpdir);
|
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 =
|
const remote_branch_exists =
|
||||||
child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, {encoding: 'utf8'}).trim().length >
|
child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, {encoding: 'utf8'}).trim().length >
|
||||||
0;
|
0;
|
||||||
if (remote_branch_exists) {
|
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 {
|
} else {
|
||||||
core.info(`🏃 Initializing local git repo`);
|
core.info(`🏃 Initializing local git repo`);
|
||||||
await exec.exec('git', ['init', '.']);
|
await exec.exec('git', ['init', '.']);
|
||||||
await exec.exec('git', ['checkout', '--orphan', target_branch]);
|
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}>`);
|
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.name', comitter_name]);
|
||||||
await exec.exec('git', ['config', 'user.email', comitter_email]);
|
await exec.exec('git', ['config', 'user.email', comitter_email]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user