Compare commits

...

8 Commits

Author SHA1 Message Date
peaceiris
f8993157cb chore(release): 3.7.0-5
Some checks failed
Release / release (push) Has been cancelled
2020-07-25 20:53:29 +09:00
peaceiris
9cf67ec63b chore(release): Add build assets 2020-07-25 20:53:27 +09:00
Shohei Ueda
0f5c65e140 feat: Add exclude_assets option (#416)
Related to #163
2020-07-25 20:52:35 +09:00
peaceiris
2046290e2b chore(release): Remove build assets [skip ci] 2020-07-25 19:37:28 +09:00
peaceiris
600bb6caa2 chore(release): 3.7.0-4
Some checks failed
Release / release (push) Has been cancelled
2020-07-25 19:37:27 +09:00
peaceiris
20912713da chore(release): Add build assets 2020-07-25 19:37:25 +09:00
Andreas Linde
674c2318ce fix: copyAssets() for destination_dir (#414) 2020-07-25 19:36:43 +09:00
peaceiris
0b4686e3a6 chore(release): Remove build assets [skip ci] 2020-07-24 21:33:54 +09:00
10 changed files with 57 additions and 9 deletions

View File

@@ -2,6 +2,24 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
# [3.7.0-5](https://github.com/peaceiris/actions-gh-pages/compare/v3.7.0-4...v3.7.0-5) (2020-07-25)
### feat
* Add exclude_assets option (#416) ([0f5c65e](https://github.com/peaceiris/actions-gh-pages/commit/0f5c65e1408b30fe461ba319ca9a01d20c293cd4)), closes [#416](https://github.com/peaceiris/actions-gh-pages/issues/416) [#163](https://github.com/peaceiris/actions-gh-pages/issues/163)
# [3.7.0-4](https://github.com/peaceiris/actions-gh-pages/compare/v3.7.0-3...v3.7.0-4) (2020-07-25)
### fix
* copyAssets() for destination_dir (#414) ([674c231](https://github.com/peaceiris/actions-gh-pages/commit/674c2318cebb9ba59aa8fbf8ec4fae8482e51e5c)), closes [#414](https://github.com/peaceiris/actions-gh-pages/issues/414)
# [3.7.0-3](https://github.com/peaceiris/actions-gh-pages/compare/v3.7.0-2...v3.7.0-3) (2020-07-24)

View File

@@ -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', () => {

View File

@@ -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();

View File

@@ -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'

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.7.0-3",
"version": "3.7.0-5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.7.0-3",
"version": "3.7.0-5",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {

View File

@@ -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;

View File

@@ -12,16 +12,34 @@ 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);
if (fs.existsSync(destPath) === false) {
await createDir(destPath);
}
await io.cp(filePublishPath, fileDestPath, copyOpts);
core.info(`[INFO] copy ${file}`);
}
@@ -50,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;
}
@@ -92,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 {
@@ -104,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;
}
}

View File

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