diff --git a/action.yml b/action.yml index 126b860..50876f0 100644 --- a/action.yml +++ b/action.yml @@ -15,5 +15,9 @@ inputs: description: This should be a token with access to the repository scoped in as a secret. This will be available in the GitHub runner environment by default as `secrets.GITHUB_TOKEN`. required: true artifactName: - description: The name of the artifact to be uploaded, for example `docs`. This will be used as the directory name within S3 for uploaded artifacts. - required: true + description: | + The name of the artifact to be uploaded, for example `docs`. + If supplied then it is used as the directory name within S3 for the uploaded artifacts, as well as within the GitHub deployment environment name. + If not supplied or supplied as an empty string then the artifacts are uploaded to S3 at root for this deployment context. + required: false + default: '' diff --git a/src/index.ts b/src/index.ts index 0a62896..947c9fd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,7 +55,7 @@ const ref = createRef(githubRef) const s3BucketName = 'sdk.ably.com'; const sourcePath = path.resolve(core.getInput('sourcePath')); -const artifactName = core.getInput('artifactName'); +const artifactName = core.getInput('artifactName').trim(); // empty string indicates no value, i.e. artifact name not specified let githubDeploymentRef: string; let s3KeyPrefix = `builds/${context.repo.owner}/${context.repo.repo}/`; @@ -76,8 +76,11 @@ if (context.eventName === 'pull_request') { core.setFailed("Error: this action can only be ran on a pull_request, a push to the 'main' branch, or a push of a tag"); process.exit(1); } -s3KeyPrefix += ('/' + artifactName); -githubEnvironmentName += ('/' + artifactName); + +if (artifactName.length > 0) { + s3KeyPrefix += ('/' + artifactName); + githubEnvironmentName += ('/' + artifactName); +} core.debug(`S3 Key Prefix: ${s3KeyPrefix}`); core.debug(`GitHub Environment Name: ${githubEnvironmentName}`);