Fix build dir

This commit is contained in:
CrazyMax 2019-11-15 16:29:46 +01:00
parent e6b7b7a697
commit 38e9e1525a
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
2 changed files with 8 additions and 6 deletions

View File

@ -58,9 +58,10 @@ function run() {
} }
remote_url = remote_url.concat('@github.com/', repo, '.git'); remote_url = remote_url.concat('@github.com/', repo, '.git');
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-')); const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-'));
const currentdir = path.resolve('.');
process.chdir(tmpdir); process.chdir(tmpdir);
core.info(`🏃 Copying ${path.resolve(build_dir)} contents to ${tmpdir}`); core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
fs_extra_1.copySync(path.resolve(build_dir), tmpdir); fs_extra_1.copySync(path.join(currentdir, build_dir), tmpdir);
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) {
@ -100,7 +101,7 @@ function run() {
gitPushCmd.push(remote_url, target_branch); gitPushCmd.push(remote_url, target_branch);
core.info(`🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo`); core.info(`🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo`);
yield exec.exec('git', gitPushCmd); yield exec.exec('git', gitPushCmd);
process.chdir(process.env['GITHUB_WORKSPACE'] || '.'); process.chdir(currentdir);
core.info(`🎉 Content of ${build_dir} has been deployed to GitHub Pages.`); core.info(`🎉 Content of ${build_dir} has been deployed to GitHub Pages.`);
} }
catch (error) { catch (error) {

View File

@ -42,10 +42,11 @@ async function run() {
remote_url = remote_url.concat('@github.com/', repo, '.git'); remote_url = remote_url.concat('@github.com/', repo, '.git');
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-')); const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-pages-'));
const currentdir = path.resolve('.');
process.chdir(tmpdir); process.chdir(tmpdir);
core.info(`🏃 Copying ${path.resolve(build_dir)} contents to ${tmpdir}`); core.info(`🏃 Copying ${path.join(currentdir, build_dir)} contents to ${tmpdir}`);
copySync(path.resolve(build_dir), tmpdir); copySync(path.join(currentdir, build_dir), tmpdir);
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 >
@ -93,7 +94,7 @@ async function run() {
core.info(`🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo`); core.info(`🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo`);
await exec.exec('git', gitPushCmd); await exec.exec('git', gitPushCmd);
process.chdir(process.env['GITHUB_WORKSPACE'] || '.'); process.chdir(currentdir);
core.info(`🎉 Content of ${build_dir} has been deployed to GitHub Pages.`); core.info(`🎉 Content of ${build_dir} has been deployed to GitHub Pages.`);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);