parent
2046290e2b
commit
0f5c65e140
|
@ -53,6 +53,7 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
|||
[INFO] TagMessage: ${inps.TagMessage}
|
||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||
[INFO] CNAME: ${inps.CNAME}
|
||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
||||
`;
|
||||
}
|
||||
|
||||
|
@ -121,6 +122,7 @@ describe('getInputs()', () => {
|
|||
expect(inps.TagMessage).toMatch('');
|
||||
expect(inps.DisableNoJekyll).toBe(false);
|
||||
expect(inps.CNAME).toMatch('');
|
||||
expect(inps.ExcludeAssets).toMatch('.github');
|
||||
});
|
||||
|
||||
test('get spec inputs', () => {
|
||||
|
@ -142,6 +144,7 @@ describe('getInputs()', () => {
|
|||
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
||||
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||
process.env['INPUT_CNAME'] = 'github.com';
|
||||
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
|
||||
|
||||
const inps: Inputs = getInputs();
|
||||
|
||||
|
@ -163,6 +166,7 @@ describe('getInputs()', () => {
|
|||
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
|
||||
expect(inps.DisableNoJekyll).toBe(true);
|
||||
expect(inps.CNAME).toMatch('github.com');
|
||||
expect(inps.ExcludeAssets).toMatch('.github');
|
||||
});
|
||||
|
||||
test('get spec inputs enable_jekyll', () => {
|
||||
|
|
|
@ -40,6 +40,7 @@ describe('setRepo()', () => {
|
|||
// process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
||||
// process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||
// process.env['INPUT_CNAME'] = 'github.com';
|
||||
process.env['INPUT_EXCLUDE_ASSETS'] = '.github';
|
||||
const inps: Inputs = getInputs();
|
||||
const remoteURL = 'https://x-access-token:pat@github.com/actions/pages.git';
|
||||
const date = new Date();
|
||||
|
|
|
@ -73,3 +73,7 @@ inputs:
|
|||
cname:
|
||||
description: 'Set custom domain'
|
||||
required: false
|
||||
exclude_assets:
|
||||
description: 'Set files or directories to exclude from a publish directory.'
|
||||
required: false
|
||||
default: '.github'
|
||||
|
|
|
@ -28,6 +28,7 @@ export function showInputs(inps: Inputs): void {
|
|||
[INFO] TagMessage: ${inps.TagMessage}
|
||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||
[INFO] CNAME: ${inps.CNAME}
|
||||
[INFO] ExcludeAssets ${inps.ExcludeAssets}
|
||||
`);
|
||||
}
|
||||
|
||||
|
@ -65,7 +66,8 @@ export function getInputs(): Inputs {
|
|||
TagName: core.getInput('tag_name'),
|
||||
TagMessage: core.getInput('tag_message'),
|
||||
DisableNoJekyll: useBuiltinJekyll,
|
||||
CNAME: core.getInput('cname')
|
||||
CNAME: core.getInput('cname'),
|
||||
ExcludeAssets: core.getInput('exclude_assets')
|
||||
};
|
||||
|
||||
return inps;
|
||||
|
|
|
@ -12,14 +12,28 @@ export async function createBranchForce(branch: string): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
export async function copyAssets(publishDir: string, destDir: string): Promise<void> {
|
||||
export async function copyAssets(
|
||||
publishDir: string,
|
||||
destDir: string,
|
||||
excludeAssets: string
|
||||
): Promise<void> {
|
||||
const copyOpts = {recursive: true, force: true};
|
||||
const files = fs.readdirSync(publishDir);
|
||||
core.debug(`${files}`);
|
||||
for await (const file of files) {
|
||||
if (file.endsWith('.git') || file.endsWith('.github')) {
|
||||
const isExcludeFile = ((): boolean => {
|
||||
const excludedAssetNames: Array<string> = excludeAssets.split(',');
|
||||
for (const excludedAssetName of excludedAssetNames) {
|
||||
if (file === excludedAssetName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})();
|
||||
if (isExcludeFile || file === '.git') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const filePublishPath = path.join(publishDir, file);
|
||||
const fileDestPath = path.join(destDir, file);
|
||||
const destPath = path.dirname(fileDestPath);
|
||||
|
@ -54,7 +68,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
|
|||
await createDir(destDir);
|
||||
process.chdir(workDir);
|
||||
await createBranchForce(inps.PublishBranch);
|
||||
await copyAssets(publishDir, destDir);
|
||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,7 +110,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
|
|||
}
|
||||
}
|
||||
|
||||
await copyAssets(publishDir, destDir);
|
||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
||||
process.chdir(workDir);
|
||||
return;
|
||||
} else {
|
||||
|
@ -108,7 +122,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
|
|||
await createDir(destDir);
|
||||
process.chdir(workDir);
|
||||
await createBranchForce(inps.PublishBranch);
|
||||
await copyAssets(publishDir, destDir);
|
||||
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ export interface Inputs {
|
|||
readonly TagMessage: string;
|
||||
readonly DisableNoJekyll: boolean;
|
||||
readonly CNAME: string;
|
||||
readonly ExcludeAssets: string;
|
||||
}
|
||||
|
||||
export interface CmdResult {
|
||||
|
|
Loading…
Reference in New Issue