mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-16 15:33:16 +08:00
feat: dry_run
This commit is contained in:
parent
25e5ffa147
commit
4ed72308bc
@ -56,6 +56,7 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
|||||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
||||||
|
[INFO] DryRun ${inps.DryRun}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +126,7 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.DisableNoJekyll).toBe(false);
|
expect(inps.DisableNoJekyll).toBe(false);
|
||||||
expect(inps.CNAME).toMatch('');
|
expect(inps.CNAME).toMatch('');
|
||||||
expect(inps.ExcludeAssets).toMatch('.github');
|
expect(inps.ExcludeAssets).toMatch('.github');
|
||||||
|
expect(inps.DryRun).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get spec inputs', () => {
|
test('get spec inputs', () => {
|
||||||
@ -147,6 +149,7 @@ describe('getInputs()', () => {
|
|||||||
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||||
process.env['INPUT_CNAME'] = 'github.com';
|
process.env['INPUT_CNAME'] = 'github.com';
|
||||||
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
|
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
|
||||||
|
process.env['INPUT_DRY_RUN'] = 'true';
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
|
|
||||||
@ -169,6 +172,7 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.DisableNoJekyll).toBe(true);
|
expect(inps.DisableNoJekyll).toBe(true);
|
||||||
expect(inps.CNAME).toMatch('github.com');
|
expect(inps.CNAME).toMatch('github.com');
|
||||||
expect(inps.ExcludeAssets).toMatch('.github');
|
expect(inps.ExcludeAssets).toMatch('.github');
|
||||||
|
expect(inps.DryRun).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get spec inputs enable_jekyll', () => {
|
test('get spec inputs enable_jekyll', () => {
|
||||||
|
@ -77,3 +77,7 @@ inputs:
|
|||||||
description: 'Set files or directories to exclude from a publish directory.'
|
description: 'Set files or directories to exclude from a publish directory.'
|
||||||
required: false
|
required: false
|
||||||
default: '.github'
|
default: '.github'
|
||||||
|
dry_run:
|
||||||
|
description: 'Set true to run the action with dry run mode.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
@ -29,6 +29,7 @@ export function showInputs(inps: Inputs): void {
|
|||||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
||||||
|
[INFO] DryRun ${inps.DryRun}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ export function getInputs(): Inputs {
|
|||||||
TagMessage: core.getInput('tag_message'),
|
TagMessage: core.getInput('tag_message'),
|
||||||
DisableNoJekyll: useBuiltinJekyll,
|
DisableNoJekyll: useBuiltinJekyll,
|
||||||
CNAME: core.getInput('cname'),
|
CNAME: core.getInput('cname'),
|
||||||
ExcludeAssets: core.getInput('exclude_assets')
|
ExcludeAssets: core.getInput('exclude_assets'),
|
||||||
|
DryRun: (core.getInput('dry_run') || 'false').toUpperCase() === 'TRUE'
|
||||||
};
|
};
|
||||||
|
|
||||||
return inps;
|
return inps;
|
||||||
|
@ -18,6 +18,7 @@ export interface Inputs {
|
|||||||
readonly DisableNoJekyll: boolean;
|
readonly DisableNoJekyll: boolean;
|
||||||
readonly CNAME: string;
|
readonly CNAME: string;
|
||||||
readonly ExcludeAssets: string;
|
readonly ExcludeAssets: string;
|
||||||
|
readonly DryRun: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CmdResult {
|
export interface CmdResult {
|
||||||
|
@ -79,8 +79,11 @@ export async function run(): Promise<void> {
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
core.startGroup('Push the commit or tag');
|
core.startGroup('Push the commit or tag');
|
||||||
|
if (!inps.DryRun) {
|
||||||
|
core.info(`[INFO] dry run mode, skip pushing`);
|
||||||
await push(inps.PublishBranch, inps.ForceOrphan);
|
await push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
await pushTag(inps.TagName, inps.TagMessage);
|
await pushTag(inps.TagName, inps.TagMessage);
|
||||||
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user