Skip to content

Commit

Permalink
Merge branch 'dev' into krmitta/ssh-support-ui-changes-1
Browse files Browse the repository at this point in the history
  • Loading branch information
takyyon authored Oct 11, 2023
2 parents 16f78f2 + e9f1cb0 commit c6ec6c2
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions server/src/deployment-center/github/github.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,63 @@ export class GithubController {
await this._makeGetCallWithLinkAndOAuthHeaders(url, gitHubToken, res);
}

@Post('api/github/getWorkflowRunLogs')
@HttpCode(200)
async getJobLogs(
@Body('gitHubToken') gitHubToken: string,
@Body('org') org: string,
@Body('repo') repo: string,
@Body('runId') runId: number,
@Res() res
) {
const url = `${this.githubApiUrl}/repos/${org}/${repo}/actions/runs/${runId}/logs`;
try {
await this.httpService
.get(url, {
headers: this._getAuthorizationHeader(gitHubToken),
responseType: 'arraybuffer',
})
.then(response => {
res.json(response.data);
});
} catch (err) {
this.loggingService.error(`Failed to get workflow run logs.`);

if (err.response) {
throw new HttpException(err.response.data, err.response.status);
}
throw new HttpException(err, 500);
}
}

@Post('api/github/getWorkflowRun')
@HttpCode(200)
async getWorkflowRun(
@Body('gitHubToken') gitHubToken: string,
@Body('org') org: string,
@Body('repo') repo: string,
@Body('runId') runId: number,
@Res() res
) {
const url = `${this.githubApiUrl}/repos/${org}/${repo}/actions/runs/${runId}`;
try {
await this.httpService
.get(url, {
headers: this._getAuthorizationHeader(gitHubToken),
})
.then(response => {
res.json(response.data);
});
} catch (err) {
this.loggingService.error(`Failed to get workflow run.`);

if (err.response) {
throw new HttpException(err.response.data, err.response.status);
}
throw new HttpException(err, 500);
}
}

@Post('api/github/deleteWorkflowRun')
@HttpCode(200)
async deleteWorkflowRun(
Expand Down

0 comments on commit c6ec6c2

Please sign in to comment.