Skip to content

Commit 5613bd5

Browse files
authored
Add verbose input (#150)
Co-authored-by: CrazyMax <[email protected]>
1 parent a2f93ef commit 5613bd5

File tree

9 files changed

+61
-20
lines changed

9 files changed

+61
-20
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
include:
2222
- target_branch: 'gh-pages'
2323
keep_history: 'false'
24+
verbose: 'true'
2425
- target_branch: 'gh-pages-keep'
2526
keep_history: 'true'
27+
verbose: 'false'
2628
steps:
2729
-
2830
name: Checkout
@@ -37,8 +39,8 @@ jobs:
3739
run: |
3840
MAXDIRS=5
3941
MAXDEPTH=5
40-
MAXFILES=10
41-
MAXSIZE=1000
42+
MAXFILES=30
43+
MAXSIZE=3000
4244
TOP=$(pwd|tr -cd '/'|wc -c)
4345
4446
populate() {
@@ -96,6 +98,7 @@ jobs:
9698
target_branch: ${{ matrix.target_branch }}
9799
keep_history: ${{ matrix.keep_history }}
98100
build_dir: public
99-
dry-run: ${{ github.event_name == 'pull_request' }}
101+
dry_run: ${{ github.event_name == 'pull_request' }}
102+
verbose: ${{ matrix.verbose }}
100103
env:
101104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## 2.4.0 (2021/05/13)
88

9-
* Add `dry-run` input (#144)
9+
* Add `dry_run` input (#144)
1010
* Refactor logging output
1111
* Bump fs-extra from 9.1.0 to 10.0.0 (#139)
1212
* Bump @actions/core from 1.2.6 to 1.2.7 (#137)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ Following inputs can be used as `step.with` keys
138138
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |
139139
| `fqdn` | String | Write the given domain name to the CNAME file |
140140
| `jekyll` | Bool | Allow Jekyll to build your site (default `true`) |
141-
| `dry-run` | Bool | If enabled, nothing will be pushed (default `false`) |
141+
| `dry_run` | Bool | If enabled, nothing will be pushed (default `false`) |
142+
| `verbose` | Bool | Enable verbose output (default `false`) |
142143

143144
### environment variables
144145

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ inputs:
4545
description: 'Allow Jekyll to build your site'
4646
default: 'true'
4747
required: false
48-
dry-run:
48+
dry_run:
4949
description: 'If enabled, nothing will be pushed'
5050
default: 'false'
5151
required: false
52+
verbose:
53+
description: 'Enable verbose output'
54+
default: 'false'
55+
required: false
5256

5357
runs:
5458
using: 'node12'

dist/index.js

Lines changed: 23 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/build.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ FROM deps AS format-validate
5656
RUN --mount=type=bind,target=.,rw \
5757
--mount=type=cache,target=/src/.yarn/cache \
5858
--mount=type=cache,target=/src/node_modules \
59-
yarn run format-check \
59+
yarn run format-check

src/git.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ export async function setConfig(key: string, value: string): Promise<void> {
5151
await exec.exec('git', ['config', key, value]);
5252
}
5353

54-
export async function add(pattern: string): Promise<void> {
55-
await exec.exec('git', ['add', '--verbose', '--all', pattern]);
54+
export async function add(pattern: string, verbose: boolean): Promise<void> {
55+
let args: Array<string> = ['add'];
56+
if (verbose) {
57+
args.push('--verbose');
58+
}
59+
args.push('--all', pattern);
60+
await exec.exec('git', args);
5661
}
5762

5863
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:
6974
}
7075

7176
export async function showStat(): Promise<string> {
72-
return await mexec.exec('git', ['show', `--stat-count=2000`, 'HEAD'], true).then(res => {
77+
return await mexec.exec('git', ['show', `--stat-count=1000`, 'HEAD'], true).then(res => {
7378
if (res.stderr != '' && !res.success) {
7479
throw new Error(res.stderr);
7580
}

src/main.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ async function run() {
1919
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
2020
const fqdn: string = core.getInput('fqdn');
2121
const nojekyll: boolean = /false/i.test(core.getInput('jekyll'));
22-
const dryRun: boolean = /true/i.test(core.getInput('dry-run'));
22+
const dryRun: boolean = /true/i.test(core.getInput('dry_run'));
23+
const verbose: boolean = /true/i.test(core.getInput('verbose'));
2324

2425
if (!fs.existsSync(buildDir)) {
2526
core.setFailed('Build dir does not exist');
@@ -60,15 +61,25 @@ async function run() {
6061
core.endGroup();
6162
}
6263

64+
let copyCount = 0;
6365
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
6466
await copy(path.join(currentdir, buildDir), tmpdir, {
6567
filter: (src, dest) => {
66-
core.info(`${src} => ${dest}`);
68+
if (verbose) {
69+
core.info(`${src} => ${dest}`);
70+
} else {
71+
if (copyCount > 1 && copyCount % 80 === 0) {
72+
process.stdout.write('\n');
73+
}
74+
process.stdout.write('.');
75+
copyCount++;
76+
}
6777
return true;
6878
}
6979
}).catch(error => {
7080
core.error(error);
7181
});
82+
core.info(`${copyCount} file(s) copied.`);
7283
});
7384

7485
if (fqdn) {
@@ -100,7 +111,7 @@ async function run() {
100111
}
101112

102113
core.startGroup(`Updating index of working tree`);
103-
await git.add('.');
114+
await git.add('.', verbose);
104115
core.endGroup();
105116

106117
const authorPrs: addressparser.Address = addressparser(author)[0];

0 commit comments

Comments
 (0)