-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the whole workflow dry-runnable
- Loading branch information
1 parent
e282c72
commit 9d94e8f
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'Upload to S3' | ||
description: 'Upload the contents of a directory to an S3 bucket' | ||
|
||
inputs: | ||
directory: | ||
description: Directory to upload | ||
required: true | ||
destination: | ||
description: S3 destination path URI | ||
required: true | ||
dry-run: | ||
description: If true, run the commands but don't actually upload | ||
required: false | ||
|
||
runs: | ||
using: 'node20' | ||
main: './main.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const execSync = require('child_process').execSync | ||
const core = require('@actions/core') | ||
|
||
/** | ||
* @fileoverview Upload a directory to S3. | ||
*/ | ||
|
||
const directory = core.getInput('directory', {required: true}) | ||
const destination = core.getInput('destination', {required: true}) | ||
const dryRun = core.getBooleanInput('dry-run') | ||
|
||
const args = ['--recursive'] | ||
if (dryRun) { | ||
args.push('--dryrun') | ||
} | ||
|
||
core.info(`Uploading ${directory} to S3.`) | ||
execSync(`aws s3 cp ${args.join(' ')} "${directory}" "${destination}"`, { stdio: 'inherit' }) | ||
// Note: the default cache policy is 1 day, I think that's OK for now. | ||
// In the future if traffic increases we can increase the expiration | ||
// as much as we want. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters