Skip to content

Commit

Permalink
Merge pull request #53 from ably/add-url-base-output
Browse files Browse the repository at this point in the history
Add URL base output
  • Loading branch information
QuintinWillison authored Feb 28, 2023
2 parents bf26209 + b779647 commit bfdddc7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This action automates the deployment of generated artifacts to our Ably SDK team

## Usage

### Usage After Artifact Generation

See [action.yml](action.yml) for explanations of each input.

```yaml
Expand Down Expand Up @@ -31,6 +33,19 @@ In the above example, `<REPO-NAME>` should be the Ably repository name (e.g. `ab

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).

### Usage Before Artifact Generation

There are times when the URL base on `sdk.ably.com` needs to be known ahead of artifact build.

This action has an input called `mode` which can be set to `"preempt"` in order to obtain this information up front.

If the preempt mode is requested then nothing will be uploaded to S3, however the action will emit an output called `url-base`,
containing the URL base as a string value. For example:

https://sdk.ably.com/builds/ably/ably-flutter/pull/307/dartdoc/

When used in the Flutter SDK repository, with `artifactName` as `"dartdoc"`.

## Permissions

### AWS
Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ inputs:
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: ''
mode:
description: |
Specify `"preempt"` in order use this action before content build in order to output the URL base.
required: false
outputs:
url-base:
description: |
The URL base. For example:
https://sdk.ably.com/builds/ably/ably-flutter/pull/307/dartdoc/
When used in the Flutter SDK repository, with `artifactName` as `"dartdoc"`.
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ if (artifactName.length > 0) {
core.debug(`S3 Key Prefix: ${s3KeyPrefix}`);
core.debug(`GitHub Environment Name: ${githubEnvironmentName}`);

const urlBase = `https://${s3BucketName}/${s3KeyPrefix}/`;
core.setOutput('url-base', urlBase);
const runMode = core.getInput('mode');
if (runMode === 'preempt') {
process.exit(0);
}

const s3ClientConfig: S3ClientConfig = {
// RegionInputConfig
region: 'eu-west-2',
Expand Down Expand Up @@ -163,7 +170,7 @@ const run = async () => {
ContentType: lookup(file) || 'application/octet-stream',
});
}));
await setDeploymentStatus(deploymentId, 'success', `https://${s3BucketName}/${s3KeyPrefix}/`);
await setDeploymentStatus(deploymentId, 'success', urlBase);
} catch (err) {
await setDeploymentStatus(deploymentId, 'failure');
throw err;
Expand Down

0 comments on commit bfdddc7

Please sign in to comment.