Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ inputs:
description: 'If existing files in the publish branch should be not removed before deploying'
required: false
default: 'false'
remove_path_spec:
description: 'Git Pathspec that should be removed before deploying'
required: false
default: '*'
force_orphan:
description: 'Keep only the latest commit on a GitHub Pages branch'
required: false
Expand Down
2 changes: 2 additions & 0 deletions src/get-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function showInputs(inps: Inputs): void {
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] RemovePathSpec: ${inps.RemovePathSpec}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
Expand Down Expand Up @@ -57,6 +58,7 @@ export function getInputs(): Inputs {
(core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
KeepFiles:
(core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',
RemovePathSpec: core.getInput('remove_path_spec'),
ForceOrphan:
(core.getInput('force_orphan') || 'false').toUpperCase() === 'TRUE',
UserName: core.getInput('user_name'),
Expand Down
8 changes: 7 additions & 1 deletion src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ export async function setRepo(
if (inps.KeepFiles) {
core.info('[INFO] Keep existing files');
} else {
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
await exec.exec('git', [
'rm',
'-r',
'--ignore-unmatch',
'--',
...inps.RemovePathSpec.split(',')
]);
}

await copyAssets(publishDir, workDir);
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Inputs {
readonly ExternalRepository: string;
readonly AllowEmptyCommit: boolean;
readonly KeepFiles: boolean;
readonly RemovePathSpec: string;
readonly ForceOrphan: boolean;
readonly UserName: string;
readonly UserEmail: string;
Expand Down