mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-22 19:59:26 +08:00
Vidya reddy/prettier code (#203)
This commit is contained in:
+31
-30
@@ -1,39 +1,40 @@
|
||||
import * as core from "@actions/core";
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { Endpoints } from "@octokit/types";
|
||||
import { retry } from "@octokit/plugin-retry";
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit} from '@octokit/core'
|
||||
import {Endpoints} from '@octokit/types'
|
||||
import {retry} from '@octokit/plugin-retry'
|
||||
|
||||
export const OkStatusCode = 200;
|
||||
export const OkStatusCode = 200
|
||||
|
||||
const RetryOctokit = Octokit.plugin(retry);
|
||||
const RETRY_COUNT = 5;
|
||||
const requestUrl = "GET /repos/{owner}/{repo}/actions/workflows";
|
||||
const RetryOctokit = Octokit.plugin(retry)
|
||||
const RETRY_COUNT = 5
|
||||
const requestUrl = 'GET /repos/{owner}/{repo}/actions/workflows'
|
||||
type responseType =
|
||||
Endpoints["GET /repos/{owner}/{repo}/actions/workflows"]["response"];
|
||||
Endpoints['GET /repos/{owner}/{repo}/actions/workflows']['response']
|
||||
|
||||
export class GitHubClient {
|
||||
private readonly repository: string;
|
||||
private readonly token: string;
|
||||
private readonly repository: string
|
||||
private readonly token: string
|
||||
|
||||
constructor(repository: string, token: string) {
|
||||
this.repository = repository;
|
||||
this.token = token;
|
||||
}
|
||||
constructor(repository: string, token: string) {
|
||||
this.repository = repository
|
||||
this.token = token
|
||||
}
|
||||
|
||||
public async getWorkflows(): Promise<responseType> {
|
||||
const octokit = new RetryOctokit({
|
||||
auth: this.token,
|
||||
request: { retries: RETRY_COUNT },
|
||||
baseUrl: process.env["GITHUB_API_URL"] || "https://api.github.com",
|
||||
});
|
||||
const [owner, repo] = this.repository.split("/");
|
||||
|
||||
core.debug(`Getting workflows for repo: ${this.repository}`);
|
||||
return Promise.resolve(
|
||||
await octokit.request(requestUrl, {
|
||||
owner,
|
||||
repo,
|
||||
// prettier-ignore
|
||||
public async getWorkflows(): Promise<responseType> {
|
||||
const octokit = new RetryOctokit({
|
||||
auth: this.token,
|
||||
request: {retries: RETRY_COUNT},
|
||||
baseUrl: process.env["GITHUB_API_URL"] || "https://api.github.com",
|
||||
})
|
||||
);
|
||||
}
|
||||
const [owner, repo] = this.repository.split('/')
|
||||
|
||||
core.debug(`Getting workflows for repo: ${this.repository}`)
|
||||
return Promise.resolve(
|
||||
await octokit.request(requestUrl, {
|
||||
owner,
|
||||
repo
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user