Skip to content

Commit

Permalink
Add filesToInlcude Option (#85)
Browse files Browse the repository at this point in the history
* add ability to provide a string regex as an Input for files to include

* update tags on readme
  • Loading branch information
nmarch213 authored Jul 7, 2022
1 parent 132b3d7 commit 95a4bd6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Input | Type | Required | Default | Description
| `noCache` | boolean | No | false | Use this parameter to specify `Cache-Control: no-cache, no-store, must-revalidate` header
| `private` | boolean | No | false | Upload files with private ACL, needed for S3 static website hosting
| `cache` | string | No | | Sets the Cache-Control: max-age=X header
| `filesToInclude` | string | No | "**" | Allows for a comma delineated Regex String that matches files to include in the deployment


### Example `workflow.yml` with S3 Deploy Action
Expand Down Expand Up @@ -64,6 +65,7 @@ jobs:
delete-removed: true
no-cache: true
private: true
filesToInclude: ".*/*,*/*,**"
```

## License
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
cache:
description: 'Sets the Cache-Control: max-age=X header'
required: false
filesToInclude:
description: 'Allows for a comma delineated Regex String that matches files to include in the deployment'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
5 changes: 3 additions & 2 deletions deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const exec = require('@actions/exec');

let deploy = function (params) {
return new Promise((resolve, reject) => {
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private, cache } = params;
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private, cache, filesToInclude } = params;

const distIdArg = distId ? `--distId ${distId}` : '';
const invalidationArg = distId ? `--invalidate "${invalidation}"` : '';
Expand All @@ -16,9 +16,10 @@ let deploy = function (params) {
const noCacheArg = noCache ? '--noCache' : '';
const privateArg = private ? '--private' : '';
const cacheFlag = cache ? `--cache ${cache}` : '';
const filesRegex = filesToInclude ? filesToInclude : '**';

try {
const command = `npx [email protected] ./** \
const command = `npx [email protected] ./${filesRegex} \
--bucket ${bucket} \
--region ${bucketRegion} \
--cwd ./ \
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ async function run() {
const noCache = getBooleanInput('no-cache');
const private = getBooleanInput('private');
const cache = core.getInput('cache') || null;
const filesToInclude = core.getInput('files-to-include') || null;

await deploy({ folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private, cache });
await deploy({ folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private, cache, filesToInclude });
} catch (error) {
core.setFailed(error.message);
}
Expand Down
7 changes: 2 additions & 5 deletions package-lock.json

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

0 comments on commit 95a4bd6

Please sign in to comment.