feat: dry_run

This commit is contained in:
peaceiris 2020-10-11 11:59:43 +09:00
parent 25e5ffa147
commit 4ed72308bc
No known key found for this signature in database
GPG Key ID: 5868468A8EBA64EC
5 changed files with 17 additions and 3 deletions

View File

@ -56,6 +56,7 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
[INFO] ExcludeAssets ${inps.ExcludeAssets}
[INFO] DryRun ${inps.DryRun}
`;
}
@ -125,6 +126,7 @@ describe('getInputs()', () => {
expect(inps.DisableNoJekyll).toBe(false);
expect(inps.CNAME).toMatch('');
expect(inps.ExcludeAssets).toMatch('.github');
expect(inps.DryRun).toBeFalsy();
});
test('get spec inputs', () => {
@ -147,6 +149,7 @@ describe('getInputs()', () => {
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
process.env['INPUT_CNAME'] = 'github.com';
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
process.env['INPUT_DRY_RUN'] = 'true';
const inps: Inputs = getInputs();
@ -169,6 +172,7 @@ describe('getInputs()', () => {
expect(inps.DisableNoJekyll).toBe(true);
expect(inps.CNAME).toMatch('github.com');
expect(inps.ExcludeAssets).toMatch('.github');
expect(inps.DryRun).toBeTruthy();
});
test('get spec inputs enable_jekyll', () => {

View File

@ -77,3 +77,7 @@ inputs:
description: 'Set files or directories to exclude from a publish directory.'
required: false
default: '.github'
dry_run:
description: 'Set true to run the action with dry run mode.'
required: false
default: 'false'

View File

@ -29,6 +29,7 @@ export function showInputs(inps: Inputs): void {
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
[INFO] ExcludeAssets ${inps.ExcludeAssets}
[INFO] DryRun ${inps.DryRun}
`);
}
@ -67,7 +68,8 @@ export function getInputs(): Inputs {
TagMessage: core.getInput('tag_message'),
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname'),
ExcludeAssets: core.getInput('exclude_assets')
ExcludeAssets: core.getInput('exclude_assets'),
DryRun: (core.getInput('dry_run') || 'false').toUpperCase() === 'TRUE'
};
return inps;

View File

@ -18,6 +18,7 @@ export interface Inputs {
readonly DisableNoJekyll: boolean;
readonly CNAME: string;
readonly ExcludeAssets: string;
readonly DryRun: boolean;
}
export interface CmdResult {

View File

@ -79,8 +79,11 @@ export async function run(): Promise<void> {
core.endGroup();
core.startGroup('Push the commit or tag');
await push(inps.PublishBranch, inps.ForceOrphan);
await pushTag(inps.TagName, inps.TagMessage);
if (!inps.DryRun) {
core.info(`[INFO] dry run mode, skip pushing`);
await push(inps.PublishBranch, inps.ForceOrphan);
await pushTag(inps.TagName, inps.TagMessage);
}
core.endGroup();
core.info('[INFO] Action successfully completed');