Add verbose
input (#150)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
a2f93efc94
commit
5613bd5086
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -21,8 +21,10 @@ jobs:
|
||||||
include:
|
include:
|
||||||
- target_branch: 'gh-pages'
|
- target_branch: 'gh-pages'
|
||||||
keep_history: 'false'
|
keep_history: 'false'
|
||||||
|
verbose: 'true'
|
||||||
- target_branch: 'gh-pages-keep'
|
- target_branch: 'gh-pages-keep'
|
||||||
keep_history: 'true'
|
keep_history: 'true'
|
||||||
|
verbose: 'false'
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
|
@ -37,8 +39,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
MAXDIRS=5
|
MAXDIRS=5
|
||||||
MAXDEPTH=5
|
MAXDEPTH=5
|
||||||
MAXFILES=10
|
MAXFILES=30
|
||||||
MAXSIZE=1000
|
MAXSIZE=3000
|
||||||
TOP=$(pwd|tr -cd '/'|wc -c)
|
TOP=$(pwd|tr -cd '/'|wc -c)
|
||||||
|
|
||||||
populate() {
|
populate() {
|
||||||
|
@ -96,6 +98,7 @@ jobs:
|
||||||
target_branch: ${{ matrix.target_branch }}
|
target_branch: ${{ matrix.target_branch }}
|
||||||
keep_history: ${{ matrix.keep_history }}
|
keep_history: ${{ matrix.keep_history }}
|
||||||
build_dir: public
|
build_dir: public
|
||||||
dry-run: ${{ github.event_name == 'pull_request' }}
|
dry_run: ${{ github.event_name == 'pull_request' }}
|
||||||
|
verbose: ${{ matrix.verbose }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
## 2.4.0 (2021/05/13)
|
## 2.4.0 (2021/05/13)
|
||||||
|
|
||||||
* Add `dry-run` input (#144)
|
* Add `dry_run` input (#144)
|
||||||
* Refactor logging output
|
* Refactor logging output
|
||||||
* Bump fs-extra from 9.1.0 to 10.0.0 (#139)
|
* Bump fs-extra from 9.1.0 to 10.0.0 (#139)
|
||||||
* Bump @actions/core from 1.2.6 to 1.2.7 (#137)
|
* Bump @actions/core from 1.2.6 to 1.2.7 (#137)
|
||||||
|
|
|
@ -138,7 +138,8 @@ Following inputs can be used as `step.with` keys
|
||||||
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |
|
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |
|
||||||
| `fqdn` | String | Write the given domain name to the CNAME file |
|
| `fqdn` | String | Write the given domain name to the CNAME file |
|
||||||
| `jekyll` | Bool | Allow Jekyll to build your site (default `true`) |
|
| `jekyll` | Bool | Allow Jekyll to build your site (default `true`) |
|
||||||
| `dry-run` | Bool | If enabled, nothing will be pushed (default `false`) |
|
| `dry_run` | Bool | If enabled, nothing will be pushed (default `false`) |
|
||||||
|
| `verbose` | Bool | Enable verbose output (default `false`) |
|
||||||
|
|
||||||
### environment variables
|
### environment variables
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,14 @@ inputs:
|
||||||
description: 'Allow Jekyll to build your site'
|
description: 'Allow Jekyll to build your site'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
dry-run:
|
dry_run:
|
||||||
description: 'If enabled, nothing will be pushed'
|
description: 'If enabled, nothing will be pushed'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
|
verbose:
|
||||||
|
description: 'Enable verbose output'
|
||||||
|
default: 'false'
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
|
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
|
@ -164,9 +164,14 @@ function setConfig(key, value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.setConfig = setConfig;
|
exports.setConfig = setConfig;
|
||||||
function add(pattern) {
|
function add(pattern, verbose) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield exec.exec('git', ['add', '--verbose', '--all', pattern]);
|
let args = ['add'];
|
||||||
|
if (verbose) {
|
||||||
|
args.push('--verbose');
|
||||||
|
}
|
||||||
|
args.push('--all', pattern);
|
||||||
|
yield exec.exec('git', args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.add = add;
|
exports.add = add;
|
||||||
|
@ -187,7 +192,7 @@ function commit(allowEmptyCommit, author, message) {
|
||||||
exports.commit = commit;
|
exports.commit = commit;
|
||||||
function showStat() {
|
function showStat() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield mexec.exec('git', ['show', `--stat-count=2000`, 'HEAD'], true).then(res => {
|
return yield mexec.exec('git', ['show', `--stat-count=1000`, 'HEAD'], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +275,8 @@ function run() {
|
||||||
const commitMessage = core.getInput('commit_message') || git.defaults.message;
|
const commitMessage = core.getInput('commit_message') || git.defaults.message;
|
||||||
const fqdn = core.getInput('fqdn');
|
const fqdn = core.getInput('fqdn');
|
||||||
const nojekyll = /false/i.test(core.getInput('jekyll'));
|
const nojekyll = /false/i.test(core.getInput('jekyll'));
|
||||||
const dryRun = /true/i.test(core.getInput('dry-run'));
|
const dryRun = /true/i.test(core.getInput('dry_run'));
|
||||||
|
const verbose = /true/i.test(core.getInput('verbose'));
|
||||||
if (!fs.existsSync(buildDir)) {
|
if (!fs.existsSync(buildDir)) {
|
||||||
core.setFailed('Build dir does not exist');
|
core.setFailed('Build dir does not exist');
|
||||||
return;
|
return;
|
||||||
|
@ -308,15 +314,26 @@ function run() {
|
||||||
yield git.checkout(targetBranch);
|
yield git.checkout(targetBranch);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
let copyCount = 0;
|
||||||
yield core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, () => __awaiter(this, void 0, void 0, function* () {
|
yield core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, () => __awaiter(this, void 0, void 0, function* () {
|
||||||
yield fs_extra_1.copy(path.join(currentdir, buildDir), tmpdir, {
|
yield fs_extra_1.copy(path.join(currentdir, buildDir), tmpdir, {
|
||||||
filter: (src, dest) => {
|
filter: (src, dest) => {
|
||||||
|
if (verbose) {
|
||||||
core.info(`${src} => ${dest}`);
|
core.info(`${src} => ${dest}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (copyCount > 1 && copyCount % 80 === 0) {
|
||||||
|
process.stdout.write('\n');
|
||||||
|
}
|
||||||
|
process.stdout.write('.');
|
||||||
|
copyCount++;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
});
|
});
|
||||||
|
core.info(`${copyCount} file(s) copied.`);
|
||||||
}));
|
}));
|
||||||
if (fqdn) {
|
if (fqdn) {
|
||||||
core.info(`Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`);
|
core.info(`Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`);
|
||||||
|
@ -342,7 +359,7 @@ function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.startGroup(`Updating index of working tree`);
|
core.startGroup(`Updating index of working tree`);
|
||||||
yield git.add('.');
|
yield git.add('.', verbose);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
const authorPrs = addressparser_1.default(author)[0];
|
const authorPrs = addressparser_1.default(author)[0];
|
||||||
yield core.group(`Committing changes`, () => __awaiter(this, void 0, void 0, function* () {
|
yield core.group(`Committing changes`, () => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -56,4 +56,4 @@ FROM deps AS format-validate
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/src/.yarn/cache \
|
--mount=type=cache,target=/src/.yarn/cache \
|
||||||
--mount=type=cache,target=/src/node_modules \
|
--mount=type=cache,target=/src/node_modules \
|
||||||
yarn run format-check \
|
yarn run format-check
|
||||||
|
|
11
src/git.ts
11
src/git.ts
|
@ -51,8 +51,13 @@ export async function setConfig(key: string, value: string): Promise<void> {
|
||||||
await exec.exec('git', ['config', key, value]);
|
await exec.exec('git', ['config', key, value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function add(pattern: string): Promise<void> {
|
export async function add(pattern: string, verbose: boolean): Promise<void> {
|
||||||
await exec.exec('git', ['add', '--verbose', '--all', pattern]);
|
let args: Array<string> = ['add'];
|
||||||
|
if (verbose) {
|
||||||
|
args.push('--verbose');
|
||||||
|
}
|
||||||
|
args.push('--all', pattern);
|
||||||
|
await exec.exec('git', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function commit(allowEmptyCommit: boolean, author: string, message: string): Promise<void> {
|
export async function commit(allowEmptyCommit: boolean, author: string, message: string): Promise<void> {
|
||||||
|
@ -69,7 +74,7 @@ export async function commit(allowEmptyCommit: boolean, author: string, message:
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function showStat(): Promise<string> {
|
export async function showStat(): Promise<string> {
|
||||||
return await mexec.exec('git', ['show', `--stat-count=2000`, 'HEAD'], true).then(res => {
|
return await mexec.exec('git', ['show', `--stat-count=1000`, 'HEAD'], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
|
|
15
src/main.ts
15
src/main.ts
|
@ -19,7 +19,8 @@ async function run() {
|
||||||
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
|
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
|
||||||
const fqdn: string = core.getInput('fqdn');
|
const fqdn: string = core.getInput('fqdn');
|
||||||
const nojekyll: boolean = /false/i.test(core.getInput('jekyll'));
|
const nojekyll: boolean = /false/i.test(core.getInput('jekyll'));
|
||||||
const dryRun: boolean = /true/i.test(core.getInput('dry-run'));
|
const dryRun: boolean = /true/i.test(core.getInput('dry_run'));
|
||||||
|
const verbose: boolean = /true/i.test(core.getInput('verbose'));
|
||||||
|
|
||||||
if (!fs.existsSync(buildDir)) {
|
if (!fs.existsSync(buildDir)) {
|
||||||
core.setFailed('Build dir does not exist');
|
core.setFailed('Build dir does not exist');
|
||||||
|
@ -60,15 +61,25 @@ async function run() {
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let copyCount = 0;
|
||||||
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
|
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
|
||||||
await copy(path.join(currentdir, buildDir), tmpdir, {
|
await copy(path.join(currentdir, buildDir), tmpdir, {
|
||||||
filter: (src, dest) => {
|
filter: (src, dest) => {
|
||||||
|
if (verbose) {
|
||||||
core.info(`${src} => ${dest}`);
|
core.info(`${src} => ${dest}`);
|
||||||
|
} else {
|
||||||
|
if (copyCount > 1 && copyCount % 80 === 0) {
|
||||||
|
process.stdout.write('\n');
|
||||||
|
}
|
||||||
|
process.stdout.write('.');
|
||||||
|
copyCount++;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
});
|
});
|
||||||
|
core.info(`${copyCount} file(s) copied.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fqdn) {
|
if (fqdn) {
|
||||||
|
@ -100,7 +111,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup(`Updating index of working tree`);
|
core.startGroup(`Updating index of working tree`);
|
||||||
await git.add('.');
|
await git.add('.', verbose);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
const authorPrs: addressparser.Address = addressparser(author)[0];
|
const authorPrs: addressparser.Address = addressparser(author)[0];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user