Skip to content

Commit

Permalink
Add mode input and URL base output.
Browse files Browse the repository at this point in the history
QuintinWillison committed Feb 28, 2023
1 parent bf26209 commit a4dba97
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
@@ -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}/`;
const runMode = core.getInput('mode');
if (runMode === 'preempt') {
core.setOutput('url-base', urlBase);
process.exit(0);
}

const s3ClientConfig: S3ClientConfig = {
// RegionInputConfig
region: 'eu-west-2',
@@ -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;

0 comments on commit a4dba97

Please sign in to comment.