Skip to content

Commit

Permalink
Merge pull request #46 from ably/make-artifact-name-optional
Browse files Browse the repository at this point in the history
Make `artifactName` input optional
  • Loading branch information
QuintinWillison authored Sep 26, 2022
2 parents 627356d + 59e5d89 commit 5ca4d72
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

- Removes support for S3 Access Key to be used to directly specify the IAM user.
GitHub OIDC is now required.
- Makes the `artifactName` Action input optional, allowing artifacts to be uploaded to the root of the deployment context.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ In the above example, `<REPO-NAME>` should be the Ably repository name (e.g. `ab
- Artifacts generated from pushes to the main branch will be uploaded to `https://sdk.ably.com/builds/ably/${repository_name}/main/${artifactName}`.
- Artifacts generated from a pushed tag will be uploaded to `https://sdk.ably.com/builds/ably/${repository_name}/tag/${tag_name}/${artifactName}`.

If `artifactName` is not specified, or specified as an empty string, then artifacts are pushed to the root of the upload context (i.e. dropping `/${artifactName}` from the URL structures outlined above).

## Permissions

### AWS
Expand Down
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: ''
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const ref = createRef(githubRef)

const s3BucketName = 'sdk.ably.com';
const sourcePath = path.resolve(core.getInput('sourcePath'));

// Optional artifactName:
// - The getInput() method calls trim() for us by default (trimWhitespace: true)
// - Empty string indicates no value, i.e. artifact name not specified
const artifactName = core.getInput('artifactName');

let githubDeploymentRef: string;
Expand All @@ -76,8 +80,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 5ca4d72

Please sign in to comment.