mirror of
https://github.com/status-im/actions-gh-pages.git
synced 2025-01-11 22:04:08 +00:00
feat: Add enable_jekyll (#143)
Implementation of `enable_jekyll` option which is an alias for `disable_nojekyll` - Issue #130 - Pull Request #132
This commit is contained in:
parent
ade8887479
commit
dc1169c5ba
13
CHANGELOG.md
13
CHANGELOG.md
@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
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.
|
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.5.0-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.1...v3.5.0-0) (2020-03-06)
|
||||||
|
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* bump node 12.15.0 to 12.16.1 (#142) ([ade8887](https://github.com/peaceiris/actions-gh-pages/commit/ade88874791f5b67d0c475d6dffb5219ed4407f1)), closes [#142](https://github.com/peaceiris/actions-gh-pages/issues/142)
|
||||||
|
|
||||||
|
### feat
|
||||||
|
|
||||||
|
* Add enable_jekyll ([1fff2ca](https://github.com/peaceiris/actions-gh-pages/commit/1fff2ca84a6b42067a86c6229774aa5e2891a661))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [3.4.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.0...v3.4.1) (2020-03-06)
|
## [3.4.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.0...v3.4.1) (2020-03-06)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,28 +2,31 @@
|
|||||||
import {Inputs} from '../src/interfaces';
|
import {Inputs} from '../src/interfaces';
|
||||||
import {showInputs, getInputs} from '../src/get-inputs';
|
import {showInputs, getInputs} from '../src/get-inputs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import fs from 'fs';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
process.stdout.write = jest.fn();
|
||||||
|
|
||||||
|
const doc = yaml.safeLoad(
|
||||||
|
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
|
||||||
|
);
|
||||||
|
Object.keys(doc.inputs).forEach(name => {
|
||||||
|
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
|
process.env[envVar] = doc.inputs[name]['default'];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
delete process.env['INPUT_DEPLOY_KEY'];
|
const doc = yaml.safeLoad(
|
||||||
delete process.env['INPUT_GITHUB_TOKEN'];
|
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
|
||||||
delete process.env['INPUT_PERSONAL_TOKEN'];
|
);
|
||||||
delete process.env['INPUT_PUBLISH_BRANCH'];
|
Object.keys(doc.inputs).forEach(name => {
|
||||||
delete process.env['INPUT_PUBLISH_DIR'];
|
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
|
||||||
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
|
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
|
||||||
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
|
delete process.env[envVar];
|
||||||
delete process.env['INPUT_KEEP_FILES'];
|
});
|
||||||
delete process.env['INPUT_FORCE_ORPHAN'];
|
|
||||||
delete process.env['INPUT_USER_NAME'];
|
|
||||||
delete process.env['INPUT_USER_EMAIL'];
|
|
||||||
delete process.env['INPUT_COMMIT_MESSAGE'];
|
|
||||||
delete process.env['INPUT_TAG_NAME'];
|
|
||||||
delete process.env['INPUT_TAG_MESSAGE'];
|
|
||||||
delete process.env['INPUT_DISABLE_NOJEKYLL'];
|
|
||||||
delete process.env['INPUT_CNAME'];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
// Assert that process.stdout.write calls called only with the given arguments.
|
||||||
@ -36,22 +39,6 @@ function assertWriteCalls(calls: string[]): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTestInputs(): void {
|
|
||||||
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
|
|
||||||
process.env['INPUT_PUBLISH_DIR'] = 'out';
|
|
||||||
process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
|
|
||||||
process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
|
|
||||||
process.env['INPUT_KEEP_FILES'] = 'true';
|
|
||||||
process.env['INPUT_FORCE_ORPHAN'] = 'true';
|
|
||||||
process.env['INPUT_USER_NAME'] = 'username';
|
|
||||||
process.env['INPUT_USER_EMAIL'] = 'github@github.com';
|
|
||||||
process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
|
|
||||||
process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
|
|
||||||
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
|
||||||
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
|
||||||
process.env['INPUT_CNAME'] = 'github.com';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInputsLog(authMethod: string, inps: Inputs): string {
|
function getInputsLog(authMethod: string, inps: Inputs): string {
|
||||||
return `\
|
return `\
|
||||||
[INFO] ${authMethod}: true
|
[INFO] ${authMethod}: true
|
||||||
@ -66,20 +53,15 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
|||||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||||
[INFO] TagName: ${inps.TagName}
|
[INFO] TagName: ${inps.TagName}
|
||||||
[INFO] TagMessage: ${inps.TagMessage}
|
[INFO] TagMessage: ${inps.TagMessage}
|
||||||
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('showInputs()', () => {
|
describe('showInputs()', () => {
|
||||||
beforeEach(() => {
|
|
||||||
process.stdout.write = jest.fn();
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line jest/expect-expect
|
||||||
test('print all inputs DeployKey', () => {
|
test('print all inputs DeployKey', () => {
|
||||||
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
||||||
setTestInputs();
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
@ -91,8 +73,8 @@ describe('showInputs()', () => {
|
|||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line jest/expect-expect
|
||||||
test('print all inputs GithubToken', () => {
|
test('print all inputs GithubToken', () => {
|
||||||
|
delete process.env['INPUT_DEPLOY_KEY'];
|
||||||
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
|
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
|
||||||
setTestInputs();
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
@ -104,8 +86,9 @@ describe('showInputs()', () => {
|
|||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
// eslint-disable-next-line jest/expect-expect
|
||||||
test('print all inputs PersonalToken', () => {
|
test('print all inputs PersonalToken', () => {
|
||||||
|
delete process.env['INPUT_DEPLOY_KEY'];
|
||||||
|
delete process.env['INPUT_GITHUB_TOKEN'];
|
||||||
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
||||||
setTestInputs();
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
@ -119,10 +102,6 @@ describe('showInputs()', () => {
|
|||||||
describe('getInputs()', () => {
|
describe('getInputs()', () => {
|
||||||
test('get default inputs', () => {
|
test('get default inputs', () => {
|
||||||
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
||||||
// process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
|
|
||||||
// process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
|
||||||
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
|
|
||||||
process.env['INPUT_PUBLISH_DIR'] = 'public';
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
|
|
||||||
@ -181,4 +160,14 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.DisableNoJekyll).toBe(true);
|
expect(inps.DisableNoJekyll).toBe(true);
|
||||||
expect(inps.CNAME).toMatch('github.com');
|
expect(inps.CNAME).toMatch('github.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('throw error enable_jekyll or disable_nojekyll', () => {
|
||||||
|
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
||||||
|
process.env['INPUT_ENABLE_JEKYLL'] = 'true';
|
||||||
|
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
getInputs();
|
||||||
|
}).toThrowError('Use either of enable_jekyll or disable_nojekyll');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -55,8 +55,12 @@ inputs:
|
|||||||
tag_message:
|
tag_message:
|
||||||
description: 'Set tag message'
|
description: 'Set tag message'
|
||||||
required: false
|
required: false
|
||||||
|
enable_jekyll:
|
||||||
|
description: 'Enable the GitHub Pages built-in Jekyll'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
disable_nojekyll:
|
disable_nojekyll:
|
||||||
description: 'Disable adding .nojekyll file to master or gh-pages branches'
|
description: 'An alias for enable_jekyll to disable adding .nojekyll file to master or gh-pages branches'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
cname:
|
cname:
|
||||||
|
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.4.1",
|
"version": "3.5.0-0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -749,6 +749,12 @@
|
|||||||
"pretty-format": "^25.1.0"
|
"pretty-format": "^25.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/js-yaml": {
|
||||||
|
"version": "3.12.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.12.2.tgz",
|
||||||
|
"integrity": "sha512-0CFu/g4mDSNkodVwWijdlr8jH7RoplRWNgovjFLEZeT+QEbbZXjBmCe3HwaWheAlCbHwomTwzZoSedeOycABug==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/json-schema": {
|
"@types/json-schema": {
|
||||||
"version": "7.0.4",
|
"version": "7.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.4.1",
|
"version": "3.5.0-0",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -57,6 +57,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.3",
|
"@types/jest": "^25.1.3",
|
||||||
|
"@types/js-yaml": "^3.12.2",
|
||||||
"@types/node": "~12",
|
"@types/node": "~12",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.22.0",
|
"@typescript-eslint/eslint-plugin": "^2.22.0",
|
||||||
"@typescript-eslint/parser": "^2.22.0",
|
"@typescript-eslint/parser": "^2.22.0",
|
||||||
@ -66,6 +67,7 @@
|
|||||||
"husky": "^4.2.3",
|
"husky": "^4.2.3",
|
||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^25.1.0",
|
"jest-circus": "^25.1.0",
|
||||||
|
"js-yaml": "^3.13.1",
|
||||||
"lint-staged": "^10.0.8",
|
"lint-staged": "^10.0.8",
|
||||||
"prettier": "1.19.1",
|
"prettier": "1.19.1",
|
||||||
"standard-version": "^7.1.0",
|
"standard-version": "^7.1.0",
|
||||||
|
@ -24,12 +24,27 @@ export function showInputs(inps: Inputs): void {
|
|||||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||||
[INFO] TagName: ${inps.TagName}
|
[INFO] TagName: ${inps.TagName}
|
||||||
[INFO] TagMessage: ${inps.TagMessage}
|
[INFO] TagMessage: ${inps.TagMessage}
|
||||||
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
|
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||||
[INFO] CNAME: ${inps.CNAME}
|
[INFO] CNAME: ${inps.CNAME}
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
|
let useBuiltinJekyll = false;
|
||||||
|
|
||||||
|
const enableJekyll: boolean =
|
||||||
|
(core.getInput('enable_jekyll') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
const disableNoJekyll: boolean =
|
||||||
|
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE';
|
||||||
|
|
||||||
|
if (enableJekyll && disableNoJekyll) {
|
||||||
|
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
|
||||||
|
} else if (enableJekyll) {
|
||||||
|
useBuiltinJekyll = true;
|
||||||
|
} else if (disableNoJekyll) {
|
||||||
|
useBuiltinJekyll = true;
|
||||||
|
}
|
||||||
|
|
||||||
const inps: Inputs = {
|
const inps: Inputs = {
|
||||||
DeployKey: core.getInput('deploy_key'),
|
DeployKey: core.getInput('deploy_key'),
|
||||||
GithubToken: core.getInput('github_token'),
|
GithubToken: core.getInput('github_token'),
|
||||||
@ -48,8 +63,7 @@ export function getInputs(): Inputs {
|
|||||||
CommitMessage: core.getInput('commit_message'),
|
CommitMessage: core.getInput('commit_message'),
|
||||||
TagName: core.getInput('tag_name'),
|
TagName: core.getInput('tag_name'),
|
||||||
TagMessage: core.getInput('tag_message'),
|
TagMessage: core.getInput('tag_message'),
|
||||||
DisableNoJekyll:
|
DisableNoJekyll: useBuiltinJekyll,
|
||||||
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
|
|
||||||
CNAME: core.getInput('cname')
|
CNAME: core.getInput('cname')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user