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