Website: Update receive-from-github webhook. (#15669)
Closes: #14900 Closes: #15666 Changes: - Updated the receive-from-github webhook to: - Log a warning if a label cannot be deleted from a pull request. - Reset the array of unfrozen PR numbers when the main branch of fleetdm/fleet is unfrozen --------- Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
This commit is contained in:
+12
-2
@@ -412,7 +412,10 @@ module.exports = {
|
||||
}, baseHeaders);
|
||||
} else if (!isHandbookPR && existingLabels.includes('#handbook')) {
|
||||
// [?] https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#remove-a-label-from-an-issue
|
||||
await sails.helpers.http.del(`https://api.github.com/repos/${owner}/${repo}/issues/${prNumber}/labels/${encodeURIComponent('#handbook')}`, {}, baseHeaders);
|
||||
await sails.helpers.http.del(`https://api.github.com/repos/${owner}/${repo}/issues/${prNumber}/labels/${encodeURIComponent('#handbook')}`, {}, baseHeaders)
|
||||
.tolerate({ exit: 'non200Response', raw: {statusCode: 404} }, (err)=>{// if the PR has gone missing, swallow the error and warn instead.
|
||||
sails.log.warn(`When trying to send a request to remove the #handbook label from PR #${prNumber} in the ${owner}/${repo} repo, an error occured. Raw error: ${require('util').inspect(err)}`);
|
||||
});
|
||||
}//fi
|
||||
|
||||
// Add the appropriate label to PRs awaiting review from the CEO so that these PRs show up in kanban.
|
||||
@@ -425,7 +428,10 @@ module.exports = {
|
||||
}, baseHeaders);
|
||||
} else if (!isPRStillDependentOnAndReadyForCeoReview && existingLabels.includes('#g-ceo')) {
|
||||
// [?] https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#remove-a-label-from-an-issue
|
||||
await sails.helpers.http.del(`https://api.github.com/repos/${owner}/${repo}/issues/${prNumber}/labels/${encodeURIComponent('#g-ceo')}`, {}, baseHeaders);
|
||||
await sails.helpers.http.del(`https://api.github.com/repos/${owner}/${repo}/issues/${prNumber}/labels/${encodeURIComponent('#g-ceo')}`, {}, baseHeaders)
|
||||
.tolerate({ exit: 'non200Response', raw: {statusCode: 404} }, (err)=>{// if the PR has gone missing, swallow the error and warn instead.
|
||||
sails.log.warn(`When trying to send a request to remove the #g-ceo label from PR #${prNumber} in the ${owner}/${repo} repo, an error occured. Raw error: ${require('util').inspect(err)}`);
|
||||
});
|
||||
}//fi
|
||||
|
||||
// ┌─┐┬ ┬┌┬┐┌─┐ ┌─┐┌─┐┌─┐┬─┐┌─┐┬ ┬┌─┐ ┬ ┬ ┬┌┐┌┌─┐┬─┐┌─┐┌─┐┌─┐┌─┐
|
||||
@@ -448,6 +454,10 @@ module.exports = {
|
||||
});
|
||||
sails.log.verbose('#'+prNumber+' is under consideration... The MergeFreeze API claims that it current main branch "frozen" status is:',mergeFreezeMainBranchStatusReport.frozen);
|
||||
let isMainBranchFrozen = mergeFreezeMainBranchStatusReport.frozen;
|
||||
// If the "main" branch is not currently frozen and we still have PR numbers in our pocketOfPrNumbersUnfrozen array. Clear out the values in the platform record.
|
||||
if(!isMainBranchFrozen && pocketOfPrNumbersUnfrozen.length > 0) {
|
||||
await Platform.updateOne({id: platformRecord.id}).set({currentUnfrozenGitHubPrNumbers: []});
|
||||
}
|
||||
if (isAutoApprovalExpected) {
|
||||
// [?] https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
|
||||
await sails.helpers.http.post(`https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}/reviews`, {
|
||||
|
||||
Reference in New Issue
Block a user