From 09ec903afaf0dab9f34e378f34aab28141bcfb5b Mon Sep 17 00:00:00 2001 From: Elmar Jansen Date: Sun, 17 Jan 2021 18:53:42 +0100 Subject: [PATCH] Add share link creation --- src/buildApi.ts | 12 ++++++++++++ src/main.ts | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/buildApi.ts b/src/buildApi.ts index 47c9393..2173df5 100644 --- a/src/buildApi.ts +++ b/src/buildApi.ts @@ -48,6 +48,18 @@ export default class BuildApi { return buildStatusResponse.data } + async createShareLink(buildtargetid: string, buildnumber: string) { + const shareEndpoint = `/orgs/${this.orgid}/projects/${this.projectid}/buildtargets/${buildtargetid}/builds/${buildnumber}/share` + const shareResponse = await this.apiPost(shareEndpoint, {}) + return shareResponse.data + } + + async getShareLink(buildtargetid: string, buildnumber: string) { + const shareEndpoint = `/orgs/${this.orgid}/projects/${this.projectid}/buildtargets/${buildtargetid}/builds/${buildnumber}/share` + const shareResponse = await this.apiGet(shareEndpoint) + return shareResponse.data + } + async apiGet(endpoint: string) { return await axios.get(this.apiUrl + endpoint, this.requestOptions) } diff --git a/src/main.ts b/src/main.ts index 9c44e86..dd80727 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,6 +18,13 @@ async function run(): Promise { const buildResult = await api.runBuild(buildtargetid) core.info(`Build finished!`) + core.setOutput('BuildResult', buildResult) + + core.info('Getting share link') + const shareResult = await api.createShareLink(buildtargetid, buildResult.build) + + core.info(`Share link: ${shareResult.shareid}`) + core.setOutput('share-link', shareResult.shareid) if (buildResult.buildStatus !== 'success') { core.setFailed(