Skip to content

Commit

Permalink
Add input options related to copy() (#161)
Browse files Browse the repository at this point in the history
* Add absolute_build_dir input option

This commit adds absolute_build_dir as an additional input. If the
option is set, the provided build_dir argument won't be treated as a
relative path to the current working directory anymore. This is helpful
in environments like Nix, where the build is output to a static folder
(for example /nix/store).

Closes #159.

* Add follow_symlinks option

This option allows symbolic links in the source directory to be
followed, recursively copying the entire directory structure.

* Update outputs

* Add missing inputs to action.yml

* Add default values to input options

This concerns absolute_build_dir and follow_symlinks.

Co-authored-by: CrazyMax <github@crazymax.dev>

Co-authored-by: CrazyMax <github@crazymax.dev>
  • Loading branch information
yrd and crazy-max committed Jan 13, 2022
1 parent cde164f commit 0c20c87
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -132,6 +132,8 @@ Following inputs can be used as `step.with` keys
| `keep_history` | Bool | Create incremental commit instead of doing push force (default `false`) |
| `allow_empty_commit` | Bool | Allow an empty commit to be created (default `true`) |
| `build_dir` | String | Build directory to deploy (**required**) |
| `absolute_build_dir` | Bool | Whether to treat `build_dir` as an absolute path (defaults to `false`, making it relative to the working directory) |
| `follow_symlinks` | Bool | If enabled, the content of symbolic links will be copied (default `false`) |
| `committer` | String | Committer name and email address as `Display Name <joe@foo.bar>` (defaults to the GitHub Actions bot user) |
| `author` | String | Author name and email address as `Display Name <joe@foo.bar>` (defaults to the GitHub Actions bot user) |
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Expand Up @@ -29,6 +29,14 @@ inputs:
build_dir:
description: 'Build directory to deploy'
required: true
absolute_build_dir:
description: 'Whether to treat build_dir as an absolute path'
default: 'false'
required: false
follow_symlinks:
description: 'If enabled, the content of symbolic links will be copied'
default: 'false'
required: false
committer:
description: 'The committer name and email address'
required: false
Expand Down
8 changes: 6 additions & 2 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.

8 changes: 6 additions & 2 deletions src/main.ts
Expand Up @@ -14,6 +14,8 @@ async function run() {
const keepHistory: boolean = /true/i.test(core.getInput('keep_history'));
const allowEmptyCommit: boolean = /true/i.test(core.getInput('allow_empty_commit'));
const buildDir: string = core.getInput('build_dir', {required: true});
const absoluteBuildDir: boolean = /true/i.test(core.getInput('absolute_build_dir'));
const followSymlinks: boolean = /true/i.test(core.getInput('follow_symlinks'));
const committer: string = core.getInput('committer') || git.defaults.committer;
const author: string = core.getInput('author') || git.defaults.author;
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
Expand Down Expand Up @@ -63,7 +65,8 @@ async function run() {

let copyCount = 0;
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
await copy(path.join(currentdir, buildDir), tmpdir, {
const sourcePath = absoluteBuildDir ? buildDir : path.join(currentdir, buildDir);
await copy(sourcePath, tmpdir, {
filter: (src, dest) => {
if (verbose) {
core.info(`${src} => ${dest}`);
Expand All @@ -75,7 +78,8 @@ async function run() {
copyCount++;
}
return true;
}
},
dereference: followSymlinks
}).catch(error => {
core.error(error);
});
Expand Down

0 comments on commit 0c20c87

Please sign in to comment.