Skip to content

Commit

Permalink
Make artifactName optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintinWillison committed Sep 26, 2022
1 parent 46cf87d commit 2e5f280
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`;
Expand All @@ -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}`);
Expand Down

0 comments on commit 2e5f280

Please sign in to comment.