mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-25 14:09:27 +08:00
Removed success run API and edited testcases.
This commit is contained in:
@@ -17,23 +17,6 @@ class GitHubClient {
|
||||
this._repository = repository;
|
||||
this._token = token;
|
||||
}
|
||||
getSuccessfulRunsOnBranch(branch, workflowFileName, force) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (force || !this._successfulRunsOnBranchPromise) {
|
||||
const lastSuccessfulRunUrl = `https://api.github.com/repos/${this._repository}/actions/workflows/${workflowFileName}/runs?status=success&branch=${branch}`;
|
||||
const webRequest = new httpClient_1.WebRequest();
|
||||
webRequest.method = "GET";
|
||||
webRequest.uri = lastSuccessfulRunUrl;
|
||||
webRequest.headers = {
|
||||
Authorization: `Bearer ${this._token}`
|
||||
};
|
||||
core.debug(`Getting last successful run for repo: ${this._repository} on branch: ${branch}`);
|
||||
const response = yield httpClient_1.sendRequest(webRequest);
|
||||
this._successfulRunsOnBranchPromise = Promise.resolve(response);
|
||||
}
|
||||
return this._successfulRunsOnBranchPromise;
|
||||
});
|
||||
}
|
||||
getWorkflows(force) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (force || !this._workflowsPromise) {
|
||||
|
||||
@@ -133,7 +133,11 @@ function annotateResources(files, kubectl, resourceTypes, allPods, annotationKey
|
||||
utility_1.checkForErrors(annotateResults, true);
|
||||
}
|
||||
function labelResources(files, kubectl, label) {
|
||||
utility_1.checkForErrors([kubectl.labelFiles(files, [`workflow=${label}`], true)], true);
|
||||
let workflowName = process.env.GITHUB_WORKFLOW;
|
||||
workflowName = workflowName.startsWith('.github/workflows/') ?
|
||||
workflowName.replace(".github/workflows/", "") : workflowName;
|
||||
const labels = [`workflowFriendlyName=${workflowName}`, `workflow=${label}`];
|
||||
utility_1.checkForErrors([kubectl.labelFiles(files, labels, true)], true);
|
||||
}
|
||||
function updateResourceObjects(filePaths, imagePullSecrets, containers) {
|
||||
const newObjectsList = [];
|
||||
|
||||
@@ -67,13 +67,13 @@ function getLastSuccessfulRunSha(kubectl, namespaceName, annotationKey) {
|
||||
return '';
|
||||
}
|
||||
else {
|
||||
if (result.stderr) {
|
||||
if (!!result.stderr) {
|
||||
core.debug(`${result.stderr}`);
|
||||
return process.env.GITHUB_SHA;
|
||||
}
|
||||
else if (result.stdout) {
|
||||
else if (!!result.stdout) {
|
||||
const annotationsSet = JSON.parse(result.stdout).metadata.annotations;
|
||||
if (!!annotationsSet[annotationKey]) {
|
||||
if (!!annotationsSet && !!annotationsSet[annotationKey]) {
|
||||
return JSON.parse(annotationsSet[annotationKey].replace(/'/g, '"')).commit;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user