From 0bbea585a5dde113c4859dd72af87aa817da835b Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 6 Nov 2019 03:02:59 +0100 Subject: [PATCH] Match vars and inputs --- .prettierrc.json | 2 +- action.yml | 4 ++-- lib/main.js | 14 ++++++-------- src/main.ts | 24 ++++++++---------------- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 0f75650..1339e9b 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "printWidth": 80, + "printWidth": 120, "tabWidth": 2, "useTabs": false, "semi": true, diff --git a/action.yml b/action.yml index b19ceba..a9f92b9 100644 --- a/action.yml +++ b/action.yml @@ -17,10 +17,10 @@ inputs: required: true comitter_name: description: 'Name of the commit author' - default: 'github-actions' + default: '' comitter_email: description: 'Email of the commit author' - default: 'username@users.noreply.github.com' + default: '@users.noreply.github.com' commit_message: description: 'Commit description' default: 'Deploy to GitHub pages' diff --git a/lib/main.js b/lib/main.js index 6425c51..d11a7c3 100644 --- a/lib/main.js +++ b/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']); diff --git a/src/main.ts b/src/main.ts index 483546a..b9a4f73 100644 --- a/src/main.ts +++ b/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']) {