Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump probot from 11.4.1 to 12.3.3 #19

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 12 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,17 +36,20 @@ 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);
}
});
};

Loading
Loading