Skip to content

Commit

Permalink
Add verbose input (#150)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max committed May 30, 2021
1 parent a2f93ef commit 5613bd5
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 20 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion action.yml
Expand Up @@ -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'
Expand Down
29 changes: 23 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hack/build.Dockerfile
Expand Up @@ -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
11 changes: 8 additions & 3 deletions src/git.ts
Expand Up @@ -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> {
Expand All @@ -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);
}
Expand Down
17 changes: 14 additions & 3 deletions src/main.ts
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 5613bd5

Please sign in to comment.