Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add URL base output #53

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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