Skip to content

Commit

Permalink
build(deps): bump probot from 11.4.1 to 12.3.3 (#19)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
  • Loading branch information
dependabot[bot] and codebytere authored Jan 2, 2024
1 parent 9cdd29d commit fb68252
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 389 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,24 @@
"test": "jest"
},
"dependencies": {
"@octokit/rest": "^18.9.1",
"@octokit/rest": "^20.0.2",
"@slack/web-api": "^6.3.0",
"probot": "^11.0.1"
"probot": "^12.3.3",
"@octokit/webhooks-types": "^5.8.0"
},
"devDependencies": {
"@slack-wrench/jest-mock-web-client": "^1.4.0",
"@types/jest": "^26.0.19",
"@types/node": "^14.14.19",
"@types/node": "^20.10.6",
"jest": "^26.6.3",
"nock": "^13.0.5",
"prettier": "^3.0.0",
"smee-client": "^1.2.2",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3"
"typescript": "^5.3.3"
},
"engines": {
"node": ">= 10.13.0"
"node": ">= 16.13.0"
},
"resolutions": {
"**/latest-version/package-json/got": "11.8.5"
Expand Down
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Probot } from 'probot';
import { EventPayloads } from '@octokit/webhooks';
import { PullRequest } from '@octokit/webhooks-types';
import { WebClient } from '@slack/web-api';
import { isQuietPeriod } from './util';

Expand All @@ -17,7 +17,7 @@ const slack = new WebClient(SLACK_BOT_TOKEN);
* Posts a message to Slack notifying the API WG that a PR needs review.
* @param pr The PR to post to Slack
*/
async function postToSlack(pr: EventPayloads.WebhookPayloadPullRequestPullRequest) {
async function postToSlack(pr: PullRequest) {
const escapedTitle = pr.title.replace(
/[&<>]/g,
(x) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' })[x]!,
Expand All @@ -36,16 +36,18 @@ async function postToSlack(pr: EventPayloads.WebhookPayloadPullRequestPullReques
// If a PR is already labeled with the API review label, it won't trigger a notification, so we want to
// notify the API WG when it becomes ready for review.
export = (app: Probot) => {
app.on(['pull_request.labeled', 'pull_request.ready_for_review'], async ({ payload }) => {
const { pull_request: pr, label, action } = payload;
app.on('pull_request.labeled', async ({ payload }) => {
const { pull_request: pr, label } = payload;

const hasAPILabel = (id?: number) => id === API_REVIEW_REQUESTED_LABEL_ID;
if (label?.id === API_REVIEW_REQUESTED_LABEL_ID) {
await postToSlack(pr);
}
});

const shouldReviewNewAPIPR = action === 'labeled' && !pr.draft && hasAPILabel(label?.id);
const shouldReviewReadyAPIPR =
action === 'ready_for_review' && pr.labels.some(({ id }) => hasAPILabel(id));
app.on('pull_request.ready_for_review', async ({ payload }) => {
const { pull_request: pr } = payload;

if (shouldReviewReadyAPIPR || shouldReviewNewAPIPR) {
if (pr.labels.some(({ id }) => id === API_REVIEW_REQUESTED_LABEL_ID)) {
await postToSlack(pr);
}
});
Expand Down
Loading

0 comments on commit fb68252

Please sign in to comment.