Skip to content

Commit

Permalink
Add share link creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ElmarJ committed Jan 17, 2021
1 parent 1b65660 commit 09ec903
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/buildApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ async function run(): Promise<void> {
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(
Expand Down

0 comments on commit 09ec903

Please sign in to comment.