Match vars and inputs
This commit is contained in:
parent
76f17c630c
commit
0bbea585a5
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"printWidth": 80,
|
||||
"printWidth": 120,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
|
|
|
@ -17,10 +17,10 @@ inputs:
|
|||
required: true
|
||||
comitter_name:
|
||||
description: 'Name of the commit author'
|
||||
default: 'github-actions'
|
||||
default: '<GITHUB_ACTOR>'
|
||||
comitter_email:
|
||||
description: 'Email of the commit author'
|
||||
default: 'username@users.noreply.github.com'
|
||||
default: '<GITHUB_ACTOR>@users.noreply.github.com'
|
||||
commit_message:
|
||||
description: 'Commit description'
|
||||
default: 'Deploy to GitHub pages'
|
||||
|
|
14
lib/main.js
14
lib/main.js
|
@ -26,11 +26,9 @@ function run() {
|
|||
const repo = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
||||
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
||||
const build_dir = core.getInput('build_dir', { required: true });
|
||||
const username = core.getInput('comitter_name') ||
|
||||
process.env['GITHUB_ACTOR'] ||
|
||||
'github-actions';
|
||||
const useremail = core.getInput('comitter_email') || `${username}@users.noreply.github.com`;
|
||||
const commitmessage = core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||
const comitter_name = core.getInput('comitter_name') || process.env['GITHUB_ACTOR'] || 'github-actions';
|
||||
const comitter_email = core.getInput('comitter_email') || `${comitter_name}@users.noreply.github.com`;
|
||||
const commit_message = core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||
if (!fs.existsSync(build_dir)) {
|
||||
core.setFailed('⛔️ Build dir does not exist');
|
||||
return;
|
||||
|
@ -38,8 +36,8 @@ function run() {
|
|||
core.info(`🏃 Deploying ${build_dir} directory to ${target_branch} branch on ${repo} repo`);
|
||||
process.chdir(build_dir);
|
||||
yield exec.exec('git', ['init']);
|
||||
yield exec.exec('git', ['config', 'user.name', username]);
|
||||
yield exec.exec('git', ['config', 'user.email', useremail]);
|
||||
yield exec.exec('git', ['config', 'user.name', comitter_name]);
|
||||
yield exec.exec('git', ['config', 'user.email', comitter_email]);
|
||||
try {
|
||||
child_process.execSync('git status --porcelain').toString();
|
||||
}
|
||||
|
@ -48,7 +46,7 @@ function run() {
|
|||
return;
|
||||
}
|
||||
yield exec.exec('git', ['add', '.']);
|
||||
yield exec.exec('git', ['commit', '--allow-empty', '-m', commitmessage]);
|
||||
yield exec.exec('git', ['commit', '--allow-empty', '-m', commit_message]);
|
||||
let gitURL = String('https://');
|
||||
if (process.env['GITHUB_PAT']) {
|
||||
gitURL = gitURL.concat(process.env['GITHUB_PAT']);
|
||||
|
|
24
src/main.ts
24
src/main.ts
|
@ -5,32 +5,24 @@ import * as fs from 'fs';
|
|||
|
||||
async function run() {
|
||||
try {
|
||||
const repo =
|
||||
core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
||||
const repo = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
||||
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
||||
const build_dir = core.getInput('build_dir', {required: true});
|
||||
const username =
|
||||
core.getInput('comitter_name') ||
|
||||
process.env['GITHUB_ACTOR'] ||
|
||||
'github-actions';
|
||||
const useremail =
|
||||
core.getInput('comitter_email') || `${username}@users.noreply.github.com`;
|
||||
const commitmessage =
|
||||
core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||
const comitter_name = core.getInput('comitter_name') || process.env['GITHUB_ACTOR'] || 'github-actions';
|
||||
const comitter_email = core.getInput('comitter_email') || `${comitter_name}@users.noreply.github.com`;
|
||||
const commit_message = core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||
|
||||
if (!fs.existsSync(build_dir)) {
|
||||
core.setFailed('⛔️ Build dir does not exist');
|
||||
return;
|
||||
}
|
||||
|
||||
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`);
|
||||
|
||||
process.chdir(build_dir);
|
||||
await exec.exec('git', ['init']);
|
||||
await exec.exec('git', ['config', 'user.name', username]);
|
||||
await exec.exec('git', ['config', 'user.email', useremail]);
|
||||
await exec.exec('git', ['config', 'user.name', comitter_name]);
|
||||
await exec.exec('git', ['config', 'user.email', comitter_email]);
|
||||
|
||||
try {
|
||||
child_process.execSync('git status --porcelain').toString();
|
||||
|
@ -40,7 +32,7 @@ async function run() {
|
|||
}
|
||||
|
||||
await exec.exec('git', ['add', '.']);
|
||||
await exec.exec('git', ['commit', '--allow-empty', '-m', commitmessage]);
|
||||
await exec.exec('git', ['commit', '--allow-empty', '-m', commit_message]);
|
||||
|
||||
let gitURL = String('https://');
|
||||
if (process.env['GITHUB_PAT']) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user