Skip to content

Commit 9461e5d

Browse files
authored
Merge pull request #373 from gwynne/patch-1
Fix mishandling of action inputs
2 parents c4c6435 + 29b35eb commit 9461e5d

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ inputs:
1414
folder-to-copy:
1515
description: "Folder to copy assets from into S3."
1616
required: false
17+
default: ""
1718
environment-prefix:
1819
description: "Prefix of the GitHub Deployment Environment. The PR number will be appended to this value."
1920
required: false
21+
default: ""
2022
index-document:
2123
description: "Index document for the S3 bucket. Defaults to index.html."
2224
required: false
25+
default: "index.html"
2326
error-document:
2427
description: "Error document for the S3 bucket. Defaults to error.html."
2528
required: false
29+
default: "error.html"
2630
token:
2731
description: "Access token used to crete and manage deployments. If both this input and the GITHUB_TOKEN environment variable are provided, this input takes precedence."
2832
required: false
33+
default: ""
2934
runs:
3035
using: "node24"
3136
main: "dist/index.js"

dist/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27979,6 +27979,12 @@ var ExitCode;
2797927979
*/
2798027980
function getInput(name, options) {
2798127981
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
27982+
if (options && options.required && !val) {
27983+
throw new Error(`Input required and not supplied: ${name}`);
27984+
}
27985+
if (options && options.trimWhitespace === false) {
27986+
return val;
27987+
}
2798227988
return val.trim();
2798327989
}
2798427990
/**
@@ -62923,12 +62929,12 @@ function isSuccessResponse(object) {
6292362929

6292462930
const main = async () => {
6292562931
try {
62926-
const bucketPrefix = getInput('bucket-prefix');
62927-
const bucketRegion = getInput('bucket-region');
62932+
const bucketPrefix = getInput('bucket-prefix', { required: true });
62933+
const bucketRegion = getInput('bucket-region', { required: true });
6292862934
const folderToCopy = getInput('folder-to-copy');
6292962935
const environmentPrefix = getInput('environment-prefix');
62930-
const indexDocument = getInput('index-document') ?? 'index.html';
62931-
const errorDocument = getInput('error-document') ?? 'error.html';
62936+
const indexDocument = getInput('index-document') || 'index.html';
62937+
const errorDocument = getInput('error-document') || 'error.html';
6293262938
const tokenFromInput = getInput('token');
6293362939
if (tokenFromInput) {
6293462940
process.env.GITHUB_TOKEN = tokenFromInput;

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/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import dayjs from 'dayjs'
77

88
const main = async () => {
99
try {
10-
const bucketPrefix = core.getInput('bucket-prefix')
11-
const bucketRegion = core.getInput('bucket-region')
10+
const bucketPrefix = core.getInput('bucket-prefix', { required: true })
11+
const bucketRegion = core.getInput('bucket-region', { required: true })
1212
const folderToCopy = core.getInput('folder-to-copy')
1313
const environmentPrefix = core.getInput('environment-prefix')
14-
const indexDocument = core.getInput('index-document') ?? 'index.html'
15-
const errorDocument = core.getInput('error-document') ?? 'error.html'
14+
const indexDocument = core.getInput('index-document') || 'index.html'
15+
const errorDocument = core.getInput('error-document') || 'error.html'
1616
const tokenFromInput = core.getInput('token')
1717

1818
if (tokenFromInput) {

0 commit comments

Comments
 (0)