Skip to content

Commit 0c20c87

Browse files
yrdcrazy-max
andauthored
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>
1 parent cde164f commit 0c20c87

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ Following inputs can be used as `step.with` keys
132132
| `keep_history` | Bool | Create incremental commit instead of doing push force (default `false`) |
133133
| `allow_empty_commit` | Bool | Allow an empty commit to be created (default `true`) |
134134
| `build_dir` | String | Build directory to deploy (**required**) |
135+
| `absolute_build_dir` | Bool | Whether to treat `build_dir` as an absolute path (defaults to `false`, making it relative to the working directory) |
136+
| `follow_symlinks` | Bool | If enabled, the content of symbolic links will be copied (default `false`) |
135137
| `committer` | String | Committer name and email address as `Display Name <joe@foo.bar>` (defaults to the GitHub Actions bot user) |
136138
| `author` | String | Author name and email address as `Display Name <joe@foo.bar>` (defaults to the GitHub Actions bot user) |
137139
| `commit_message` | String | Commit message (default `Deploy to GitHub pages`) |

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ inputs:
2929
build_dir:
3030
description: 'Build directory to deploy'
3131
required: true
32+
absolute_build_dir:
33+
description: 'Whether to treat build_dir as an absolute path'
34+
default: 'false'
35+
required: false
36+
follow_symlinks:
37+
description: 'If enabled, the content of symbolic links will be copied'
38+
default: 'false'
39+
required: false
3240
committer:
3341
description: 'The committer name and email address'
3442
required: false

dist/index.js

Lines changed: 6 additions & 2 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.

src/main.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ async function run() {
1414
const keepHistory: boolean = /true/i.test(core.getInput('keep_history'));
1515
const allowEmptyCommit: boolean = /true/i.test(core.getInput('allow_empty_commit'));
1616
const buildDir: string = core.getInput('build_dir', {required: true});
17+
const absoluteBuildDir: boolean = /true/i.test(core.getInput('absolute_build_dir'));
18+
const followSymlinks: boolean = /true/i.test(core.getInput('follow_symlinks'));
1719
const committer: string = core.getInput('committer') || git.defaults.committer;
1820
const author: string = core.getInput('author') || git.defaults.author;
1921
const commitMessage: string = core.getInput('commit_message') || git.defaults.message;
@@ -63,7 +65,8 @@ async function run() {
6365

6466
let copyCount = 0;
6567
await core.group(`Copying ${path.join(currentdir, buildDir)} to ${tmpdir}`, async () => {
66-
await copy(path.join(currentdir, buildDir), tmpdir, {
68+
const sourcePath = absoluteBuildDir ? buildDir : path.join(currentdir, buildDir);
69+
await copy(sourcePath, tmpdir, {
6770
filter: (src, dest) => {
6871
if (verbose) {
6972
core.info(`${src} => ${dest}`);
@@ -75,7 +78,8 @@ async function run() {
7578
copyCount++;
7679
}
7780
return true;
78-
}
81+
},
82+
dereference: followSymlinks
7983
}).catch(error => {
8084
core.error(error);
8185
});

0 commit comments

Comments
 (0)