Skip to content

Commit ea73c1c

Browse files
committed
Copy files after clone
1 parent 6795b3f commit ea73c1c

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

lib/main.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ function run() {
3939
core.setFailed('⛔️ Build dir does not exist');
4040
return;
4141
}
42-
if (fqdn) {
43-
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`);
44-
fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim());
45-
}
4642
let remote_url = String('https://');
4743
if (process.env['GITHUB_PAT']) {
4844
core.info(`✅ Use GITHUB_PAT`);
@@ -60,19 +56,22 @@ function run() {
6056
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-'));
6157
const currentdir = path.resolve('.');
6258
process.chdir(tmpdir);
63-
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
64-
fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir);
65-
yield exec.exec('ls', ['-al']);
6659
const remote_branch_exists = child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, { encoding: 'utf8' }).trim().length >
6760
0;
6861
if (remote_branch_exists) {
69-
yield exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url]);
62+
yield exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url, '.']);
7063
}
7164
else {
7265
core.info(`🏃 Initializing local git repo`);
7366
yield exec.exec('git', ['init', '.']);
7467
yield exec.exec('git', ['checkout', '--orphan', target_branch]);
7568
}
69+
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
70+
fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir);
71+
if (fqdn) {
72+
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`);
73+
fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim());
74+
}
7675
core.info(`🔨 Configuring git committer to be ${comitter_name} <${comitter_email}>`);
7776
yield exec.exec('git', ['config', 'user.name', comitter_name]);
7877
yield exec.exec('git', ['config', 'user.email', comitter_email]);

src/main.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ async function run() {
2323
return;
2424
}
2525

26-
if (fqdn) {
27-
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`);
28-
fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim());
29-
}
30-
3126
let remote_url = String('https://');
3227
if (process.env['GITHUB_PAT']) {
3328
core.info(`✅ Use GITHUB_PAT`);
@@ -45,21 +40,25 @@ async function run() {
4540
const currentdir = path.resolve('.');
4641
process.chdir(tmpdir);
4742

48-
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
49-
copySync(path.join(currentdir, build_dir), tmpdir);
50-
await exec.exec('ls', ['-al']);
51-
5243
const remote_branch_exists =
5344
child_process.execSync(`git ls-remote --heads ${remote_url} ${target_branch}`, {encoding: 'utf8'}).trim().length >
5445
0;
5546
if (remote_branch_exists) {
56-
await exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url]);
47+
await exec.exec('git', ['clone', '--quiet', '--branch', target_branch, '--depth', '1', remote_url, '.']);
5748
} else {
5849
core.info(`🏃 Initializing local git repo`);
5950
await exec.exec('git', ['init', '.']);
6051
await exec.exec('git', ['checkout', '--orphan', target_branch]);
6152
}
6253

54+
core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
55+
copySync(path.join(currentdir, build_dir), tmpdir);
56+
57+
if (fqdn) {
58+
core.info(`✍️ Writing ${fqdn} domain name to ${path.join(build_dir, 'CNAME')}`);
59+
fs.writeFileSync(path.join(build_dir, 'CNAME'), fqdn.trim());
60+
}
61+
6362
core.info(`🔨 Configuring git committer to be ${comitter_name} <${comitter_email}>`);
6463
await exec.exec('git', ['config', 'user.name', comitter_name]);
6564
await exec.exec('git', ['config', 'user.email', comitter_email]);

0 commit comments

Comments
 (0)