Add input options related to copy() (#161)

* 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>
This commit is contained in:
Yannik Rödel 2022-01-13 10:51:54 +01:00 committed by GitHub
parent cde164fd08
commit 0c20c87f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 5 deletions

View File

@ -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`) |

View File

@ -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

8
dist/index.js generated vendored
View File

@ -270,6 +270,8 @@ function run() {
const keepHistory = /true/i.test(core.getInput('keep_history'));
const allowEmptyCommit = /true/i.test(core.getInput('allow_empty_commit'));
const buildDir = core.getInput('build_dir', { required: true });
const absoluteBuildDir = /true/i.test(core.getInput('absolute_build_dir'));
const followSymlinks = /true/i.test(core.getInput('follow_symlinks'));
const committer = core.getInput('committer') || git.defaults.committer;
const author = core.getInput('author') || git.defaults.author;
const commitMessage = core.getInput('commit_message') || git.defaults.message;
@ -316,7 +318,8 @@ function run() {
}
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, {
const sourcePath = absoluteBuildDir ? buildDir : path.join(currentdir, buildDir);
yield fs_extra_1.copy(sourcePath, tmpdir, {
filter: (src, dest) => {
if (verbose) {
core.info(`${src} => ${dest}`);
@ -329,7 +332,8 @@ function run() {
copyCount++;
}
return true;
}
},
dereference: followSymlinks
}).catch(error => {
core.error(error);
});

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -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;
@ -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}`);
@ -75,7 +78,8 @@ async function run() {
copyCount++;
}
return true;
}
},
dereference: followSymlinks
}).catch(error => {
core.error(error);
});