Compare commits

..

11 Commits

Author SHA1 Message Date
peaceiris
25ae83ba65 chore(release): 3.6.0-0
Some checks failed
Release / release (push) Has been cancelled
2020-03-07 06:25:48 +09:00
peaceiris
ce50d1857c chore(release): Add build assets 2020-03-07 06:25:48 +09:00
peaceiris
46146058b6 fix: Use io.cp() on windows 2020-03-07 06:19:48 +09:00
peaceiris
5d8f5a15f7 feat: Use rsync instead of io.cp() 2020-03-06 21:10:16 +00:00
peaceiris
fab0628782 chore(release): Remove build assets [skip ci] 2020-03-07 05:46:57 +09:00
peaceiris
73ceb68759 chore(release): 3.5.0
Some checks failed
Release / release (push) Has been cancelled
2020-03-07 05:46:57 +09:00
peaceiris
162bc9ee63 chore(release): Add build assets 2020-03-07 05:46:56 +09:00
Christoph Zwerschke
b76751b9ee docs: improve description of enable_jekyll=disable_nojekyll (see #130) (#132)
This assumes `enable_jekyll` is implemented as (the preferred) alias for `disable_nojekyll`

Close #130
2020-03-07 05:45:47 +09:00
Shohei Ueda
dc1169c5ba feat: Add enable_jekyll (#143)
Implementation of `enable_jekyll` option which is an alias for `disable_nojekyll`

- Issue #130 
- Pull Request #132
2020-03-07 05:30:51 +09:00
Shohei Ueda
ade8887479 deps: bump node 12.15.0 to 12.16.1 (#142)
* deps: bump node 12.15.0 to 12.16.1
* deps: bump git 2.25.0 to 2.25.1
* chore: validate node and npm version by engines field
* ci: Add npm i -g npm
2020-03-07 02:54:14 +09:00
peaceiris
2a9e88ed57 chore(release): Remove build assets [skip ci] 2020-03-07 00:50:04 +09:00
13 changed files with 204 additions and 90 deletions

View File

@@ -41,6 +41,14 @@ jobs:
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm i -g npm
- name: Dump version
run: |
node -v
npm --version
git --version
- run: npm ci
- name: Remove lint-staged husky

View File

@@ -29,7 +29,6 @@ jobs:
- 'macos-latest'
- 'windows-latest'
steps:
- uses: actions/checkout@v2
- name: Read .nvmrc
@@ -41,6 +40,14 @@ jobs:
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm i -g npm
- name: Dump version
run: |
node -v
npm --version
git --version
- run: npm ci
- name: Run prettier

2
.nvmrc
View File

@@ -1 +1 @@
12.15.0
12.16.1

View File

@@ -2,6 +2,49 @@
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.6.0-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.0...v3.6.0-0) (2020-03-06)
### feat
* Use rsync instead of io.cp() ([5d8f5a1](https://github.com/peaceiris/actions-gh-pages/commit/5d8f5a15f78784a868a9744f3b343232dbcbd918))
### fix
* Use io.cp() on windows ([4614605](https://github.com/peaceiris/actions-gh-pages/commit/46146058b69b014134a7d788299d643e83cc3176))
# [3.5.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.1...v3.5.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)
### docs
* improve description of enable_jekyll=disable_nojekyll (see #130) (#132) ([b76751b](https://github.com/peaceiris/actions-gh-pages/commit/b76751b9eefaaf771ce31d8ef3c69a8d907f535d)), closes [#130](https://github.com/peaceiris/actions-gh-pages/issues/130) [#132](https://github.com/peaceiris/actions-gh-pages/issues/132) [#130](https://github.com/peaceiris/actions-gh-pages/issues/130)
### feat
* Add enable_jekyll (#143) ([dc1169c](https://github.com/peaceiris/actions-gh-pages/commit/dc1169c5baf9ed1205d6f0f9c9ce0e6d26afb164)), closes [#143](https://github.com/peaceiris/actions-gh-pages/issues/143) [#130](https://github.com/peaceiris/actions-gh-pages/issues/130) [#132](https://github.com/peaceiris/actions-gh-pages/issues/132)
# [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)

View File

@@ -11,11 +11,13 @@ RUN apt-get update && \
ca-certificates \
wget \
ssh \
rsync \
vim && \
rm -rf /var/lib/apt/lists/*
rm -rf /var/lib/apt/lists/* && \
npm i -g npm
WORKDIR /git
ENV GIT_VERSION="2.25.0"
ENV GIT_VERSION="2.25.1"
RUN wget -q "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" && \
tar -zxf "./v${GIT_VERSION}.tar.gz" && \
rm "./v${GIT_VERSION}.tar.gz" && \

View File

@@ -67,7 +67,7 @@ Three tokens are supported.
- [⭐️ `deploy_key`](#%EF%B8%8F-deploy_key)
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
- [⭐️ CNAME](#%EF%B8%8F-cname)
- [⭐️ Disable `.nojekyll`](#%EF%B8%8F-disable-nojekyll)
- [⭐️ Enable Jekyll](#%EF%B8%8F-enable-jekyll)
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits)
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
@@ -231,11 +231,14 @@ For more details about `CNAME`, read the official documentation: [Managing a cus
cname: github.com
```
### ⭐️ Disable `.nojekyll`
### ⭐️ Enable Jekyll
By default, this action adds the `.nojekyll` file to only the `master` and `gh-pages` branches. When the file already exists, this action does nothing.
If you want GitHub Pages to process the site with the static site generator Jekyll, set `enable_jekyll` to true.
By default, this action signals to GitHub Pages that the site shall not be processed with Jekyll. This is done by adding an empty `.nojekyll` file when publishing to the master or gh-pages branch. When a `.nojekyll` file already exists, this action does nothing.
Bypassing Jekyll makes the deployment faster and is necessary if you are deploying files or directories that start with underscores, since Jekyll considers these to be special resources and does not copy them to the final site. You only need to set `enable_jekyll` to true when you want to deploy a Jekyll-powered website and let GitHub Pages do the Jekyll processing.
To disable this behavior, we can set the `disable_nojekyll` option to `true`.
```yaml
- name: Deploy
@@ -243,7 +246,7 @@ To disable this behavior, we can set the `disable_nojekyll` option to `true`.
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
disable_nojekyll: true
enable_jekyll: true
```
For more details about `.nojekyll`: [Bypassing Jekyll on GitHub Pages - The GitHub Blog](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/)

View File

@@ -2,28 +2,31 @@
import {Inputs} from '../src/interfaces';
import {showInputs, getInputs} from '../src/get-inputs';
import os from 'os';
import fs from 'fs';
import yaml from 'js-yaml';
beforeEach(() => {
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(() => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
delete process.env['INPUT_PERSONAL_TOKEN'];
delete process.env['INPUT_PUBLISH_BRANCH'];
delete process.env['INPUT_PUBLISH_DIR'];
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
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'];
const doc = yaml.safeLoad(
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
);
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
delete process.env[envVar];
});
});
// 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 {
return `\
[INFO] ${authMethod}: true
@@ -66,20 +53,15 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`;
}
describe('showInputs()', () => {
beforeEach(() => {
process.stdout.write = jest.fn();
});
// eslint-disable-next-line jest/expect-expect
test('print all inputs DeployKey', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
setTestInputs();
const inps: Inputs = getInputs();
showInputs(inps);
@@ -91,8 +73,8 @@ describe('showInputs()', () => {
// eslint-disable-next-line jest/expect-expect
test('print all inputs GithubToken', () => {
delete process.env['INPUT_DEPLOY_KEY'];
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
setTestInputs();
const inps: Inputs = getInputs();
showInputs(inps);
@@ -104,8 +86,9 @@ describe('showInputs()', () => {
// eslint-disable-next-line jest/expect-expect
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';
setTestInputs();
const inps: Inputs = getInputs();
showInputs(inps);
@@ -119,10 +102,6 @@ describe('showInputs()', () => {
describe('getInputs()', () => {
test('get default inputs', () => {
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();
@@ -181,4 +160,14 @@ describe('getInputs()', () => {
expect(inps.DisableNoJekyll).toBe(true);
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');
});
});

View File

@@ -55,8 +55,12 @@ inputs:
tag_message:
description: 'Set tag message'
required: false
enable_jekyll:
description: 'Enable the GitHub Pages built-in Jekyll'
required: false
default: 'false'
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
default: 'false'
cname:

View File

@@ -6068,12 +6068,24 @@ function showInputs(inps) {
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`);
}
exports.showInputs = showInputs;
function getInputs() {
let useBuiltinJekyll = false;
const enableJekyll = (core.getInput('enable_jekyll') || 'false').toUpperCase() === 'TRUE';
const disableNoJekyll = (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 = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
@@ -6089,7 +6101,7 @@ function getInputs() {
CommitMessage: core.getInput('commit_message'),
TagName: core.getInput('tag_name'),
TagMessage: core.getInput('tag_message'),
DisableNoJekyll: (core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname')
};
return inps;
@@ -8423,26 +8435,39 @@ exports.createBranchForce = createBranchForce;
function copyAssets(publishDir, workDir) {
var e_1, _a;
return __awaiter(this, void 0, void 0, function* () {
const copyOpts = { recursive: true, force: true };
const files = fs_1.default.readdirSync(publishDir);
core.debug(`${files}`);
try {
for (var files_1 = __asyncValues(files), files_1_1; files_1_1 = yield files_1.next(), !files_1_1.done;) {
const file = files_1_1.value;
if (file.endsWith('.git') || file.endsWith('.github')) {
continue;
if (process.platform === 'win32') {
const copyOpts = { recursive: true, force: true };
const files = fs_1.default.readdirSync(publishDir);
core.debug(`${files}`);
try {
for (var files_1 = __asyncValues(files), files_1_1; files_1_1 = yield files_1.next(), !files_1_1.done;) {
const file = files_1_1.value;
if (file.endsWith('.git') || file.endsWith('.github')) {
continue;
}
const filePath = path_1.default.join(publishDir, file);
yield io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
}
const filePath = path_1.default.join(publishDir, file);
yield io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (files_1_1 && !files_1_1.done && (_a = files_1.return)) yield _a.call(files_1);
}
finally { if (e_1) throw e_1.error; }
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (files_1_1 && !files_1_1.done && (_a = files_1.return)) yield _a.call(files_1);
}
finally { if (e_1) throw e_1.error; }
else {
yield exec.exec('rsync', [
'-rptgoDv',
'--copy-links',
'--copy-dirlinks',
"--exclude='.git'",
"--exclude='.github'",
`${publishDir}/`,
`${workDir}/`
]);
}
return;
});

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.4.1",
"version": "3.6.0-0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -749,6 +749,12 @@
"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": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",

View File

@@ -1,11 +1,11 @@
{
"name": "actions-github-pages",
"version": "3.4.1",
"version": "3.6.0-0",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {
"node": ">=12.14.1",
"npm": ">=6.13.7"
"node": ">=12.16.1",
"npm": ">=6.14.2"
},
"scripts": {
"lint": "eslint ./{src,__tests__}/**/*.ts",
@@ -57,6 +57,7 @@
},
"devDependencies": {
"@types/jest": "^25.1.3",
"@types/js-yaml": "^3.12.2",
"@types/node": "~12",
"@typescript-eslint/eslint-plugin": "^2.22.0",
"@typescript-eslint/parser": "^2.22.0",
@@ -66,6 +67,7 @@
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest-circus": "^25.1.0",
"js-yaml": "^3.13.1",
"lint-staged": "^10.0.8",
"prettier": "1.19.1",
"standard-version": "^7.1.0",

View File

@@ -24,12 +24,27 @@ export function showInputs(inps: Inputs): void {
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`);
}
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 = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
@@ -48,8 +63,7 @@ export function getInputs(): Inputs {
CommitMessage: core.getInput('commit_message'),
TagName: core.getInput('tag_name'),
TagMessage: core.getInput('tag_message'),
DisableNoJekyll:
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname')
};

View File

@@ -17,18 +17,29 @@ export async function copyAssets(
publishDir: string,
workDir: 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')) {
continue;
if (process.platform === 'win32') {
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')) {
continue;
}
const filePath = path.join(publishDir, file);
await io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
}
const filePath = path.join(publishDir, file);
await io.cp(filePath, `${workDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
} else {
await exec.exec('rsync', [
'-rptgoDv',
'--copy-links',
'--copy-dirlinks',
"--exclude='.git'",
"--exclude='.github'",
`${publishDir}/`,
`${workDir}/`
]);
}
return;
}