Add verbose input (#150)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-05-30 05:00:48 +02:00 committed by GitHub
parent a2f93efc94
commit 5613bd5086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 20 deletions

View File

@ -21,8 +21,10 @@ jobs:
include:
- target_branch: 'gh-pages'
keep_history: 'false'
verbose: 'true'
- target_branch: 'gh-pages-keep'
keep_history: 'true'
verbose: 'false'
steps:
-
name: Checkout
@ -37,8 +39,8 @@ jobs:
run: |
MAXDIRS=5
MAXDEPTH=5
MAXFILES=10
MAXSIZE=1000
MAXFILES=30
MAXSIZE=3000
TOP=$(pwd|tr -cd '/'|wc -c)
populate() {
@ -96,6 +98,7 @@ jobs:
target_branch: ${{ matrix.target_branch }}
keep_history: ${{ matrix.keep_history }}
build_dir: public
dry-run: ${{ github.event_name == 'pull_request' }}
dry_run: ${{ github.event_name == 'pull_request' }}
verbose: ${{ matrix.verbose }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -6,7 +6,7 @@
## 2.4.0 (2021/05/13)
* Add `dry-run` input (#144)
* Add `dry_run` input (#144)
* Refactor logging output
* Bump fs-extra from 9.1.0 to 10.0.0 (#139)
* Bump @actions/core from 1.2.6 to 1.2.7 (#137)

View File

@ -138,7 +138,8 @@ Following inputs can be used as `step.with` keys
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |
| `fqdn` | String | Write the given domain name to the CNAME file |
| `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

View File

@ -45,10 +45,14 @@ inputs:
description: 'Allow Jekyll to build your site'
default: 'true'
required: false
dry-run:
dry_run:
description: 'If enabled, nothing will be pushed'
default: 'false'
required: false
verbose:
description: 'Enable verbose output'
default: 'false'
required: false
runs:
using: 'node12'

29
dist/index.js generated vendored
View File

@ -164,9 +164,14 @@ function setConfig(key, value) {
});
}
exports.setConfig = setConfig;
function add(pattern) {
function add(pattern, verbose) {
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;
@ -187,7 +192,7 @@ function commit(allowEmptyCommit, author, message) {
exports.commit = commit;
function showStat() {
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) {
throw new Error(res.stderr);
}
@ -270,7 +275,8 @@ function run() {
const commitMessage = core.getInput('commit_message') || git.defaults.message;
const fqdn = core.getInput('fqdn');
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)) {
core.setFailed('Build dir does not exist');
return;
@ -308,15 +314,26 @@ function run() {
yield git.checkout(targetBranch);
core.endGroup();
}
let copyCount = 0;
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, {
filter: (src, dest) => {
core.info(`${src} => ${dest}`);
if (verbose) {
core.info(`${src} => ${dest}`);
}
else {
if (copyCount > 1 && copyCount % 80 === 0) {
process.stdout.write('\n');
}
process.stdout.write('.');
copyCount++;
}
return true;
}
}).catch(error => {
core.error(error);
});
core.info(`${copyCount} file(s) copied.`);
}));
if (fqdn) {
core.info(`Writing ${fqdn} domain name to ${path.join(tmpdir, 'CNAME')}`);
@ -342,7 +359,7 @@ function run() {
return;
}
core.startGroup(`Updating index of working tree`);
yield git.add('.');
yield git.add('.', verbose);
core.endGroup();
const authorPrs = addressparser_1.default(author)[0];
yield core.group(`Committing changes`, () => __awaiter(this, void 0, void 0, function* () {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -56,4 +56,4 @@ FROM deps AS format-validate
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn run format-check \
yarn run format-check

View File

@ -51,8 +51,13 @@ export async function setConfig(key: string, value: string): Promise<void> {
await exec.exec('git', ['config', key, value]);
}
export async function add(pattern: string): Promise<void> {
await exec.exec('git', ['add', '--verbose', '--all', pattern]);
export async function add(pattern: string, verbose: boolean): Promise<void> {
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> {
@ -69,7 +74,7 @@ export async function commit(allowEmptyCommit: boolean, author: string, message:
}
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) {
throw new Error(res.stderr);
}

View File

@ -19,7 +19,8 @@ async function run() {
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
const fqdn: string = core.getInput('fqdn');
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)) {
core.setFailed('Build dir does not exist');
@ -60,15 +61,25 @@ async function run() {
core.endGroup();
}
let copyCount = 0;
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
await copy(path.join(currentdir, buildDir), tmpdir, {
filter: (src, dest) => {
core.info(`${src} => ${dest}`);
if (verbose) {
core.info(`${src} => ${dest}`);
} else {
if (copyCount > 1 && copyCount % 80 === 0) {
process.stdout.write('\n');
}
process.stdout.write('.');
copyCount++;
}
return true;
}
}).catch(error => {
core.error(error);
});
core.info(`${copyCount} file(s) copied.`);
});
if (fqdn) {
@ -100,7 +111,7 @@ async function run() {
}
core.startGroup(`Updating index of working tree`);
await git.add('.');
await git.add('.', verbose);
core.endGroup();
const authorPrs: addressparser.Address = addressparser(author)[0];