Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation of s3-deploy's "--file-prefix" #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ with:

S3 Deploy's Action supports inputs from the user listed in the table below:

Input | Type | Required | Default | Description
--------------------| ---------------- | -------- | ------------ | -----------
| `folder` | string | Yes | | The folder to upload
| `bucket` | string | Yes | | The destination bucket
| `bucket-region` | string | Yes | | The destination bucket region
| `dist-id` | string | No | undefined | The CloudFront Distribution ID to invalidate
| `invalidation` | string | No | '/' | The CloudFront Distribution path(s) to invalidate
| `delete-removed` | boolean / string | No | false | Removes files in S3, that are not available in the local copy of the directory
| `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
| `immutable` | boolean | No | false | Sets the Cache-Control header to 'immutable'
| `files-to-include` | string | No | "**" | Allows for a comma delineated Regex String that matches files to include in the deployment
Input | Type | Required | Default | Description
--------------------| ---------------- | -------- | ---------- | -----------
| `folder` | string | Yes | | The folder to upload
| `bucket` | string | Yes | | The destination bucket
| `bucket-region` | string | Yes | | The destination bucket region
| `file-prefix` | string | No | | The destination prefix within the S3 bucket to upload files into. Defaults the root of the bucket.
| `dist-id` | string | No | undefined | The CloudFront Distribution ID to invalidate
| `invalidation` | string | No | '/' | The CloudFront Distribution path(s) to invalidate
| `delete-removed` | boolean / string | No | false | Removes files in S3, that are not available in the local copy of the directory
| `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
| `immutable` | boolean | No | false | Sets the Cache-Control header to 'immutable'
| `files-to-include` | 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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ inputs:
files-to-include:
description: 'Allows for a comma delineated Regex String that matches files to include in the deployment'
required: false
file-prefix:
description: 'Prefix to place files in, within the destination S3 bucket'
required: false
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
6 changes: 4 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, immutable, filesToInclude } = params;
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private, cache, immutable, filesToInclude, filePrefix } = params;

const distIdArg = distId ? `--distId ${distId}` : '';
const invalidationArg = distId ? `--invalidate "${invalidation}"` : '';
Expand All @@ -17,7 +17,8 @@ let deploy = function (params) {
const immutableArg = immutable ? '--immutable' : '';
const privateArg = private ? '--private' : '';
const cacheFlag = cache ? `--cache ${cache}` : '';
const filesRegex = filesToInclude ? filesToInclude : '**';
const filesRegex = filesToInclude ? filesToInclude : '**';
const filePrefixFlag = filePrefix ? `--filePrefix ${filePrefix}` : '';

try {
const command = `npx [email protected] ./${filesRegex} \
Expand All @@ -32,6 +33,7 @@ let deploy = function (params) {
${deleteRemovedArg} \
${noCacheArg} \
${immutableArg} \
${filePrefixFlag} \
${privateArg} `;

const cwd = path.resolve(folder);
Expand Down
Loading