diff --git a/package-lock.json b/package-lock.json index 5c8d478..5393c16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,11 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@actions/core": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz", - "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" - }, "@actions/github": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@actions/github/-/github-4.0.0.tgz", diff --git a/package.json b/package.json index 08516a4..09b2e0d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "author": "", "license": "ISC", "dependencies": { - "@actions/core": "^1.2.5", "@actions/github": "^4.0.0", "ts-node": "^9.0.0", "typescript": "^4.0.2" diff --git a/src/main-pr-review-reminders.ts b/src/main-pr-review-reminders.ts index 131dde6..7ccb831 100644 --- a/src/main-pr-review-reminders.ts +++ b/src/main-pr-review-reminders.ts @@ -1,4 +1,3 @@ -import * as core from "@actions/core"; import * as github from "@actions/github"; const token = process.env.TOKEN; @@ -20,6 +19,43 @@ async function run(): Promise { for (const pr of pullRequests) { console.log(`${pr.title} (${pr.number})`); + let thereAreBlockerLabels = false; + for (const label of pr.labels) { + if (label.name.toUpperCase().startsWith("DO NOT MERGE") || label.name.toUpperCase().startsWith("WIP")) { + thereAreBlockerLabels = true; + } + } + if (thereAreBlockerLabels) continue; + + // cleaning up old glados comments. + // comments are sorted by default + const comments = await octokit.request( + "GET " + pr.comments_url + "?per_page=1000" + ); + if (comments?.data?.length >= 1) { + const filteredComments = comments.data.filter( + (c) => c?.user?.login === "GladosBlueWallet" && c?.body?.includes('Wake the fuck up samurai') + ); + + for (const comment of filteredComments) { + if (comment.created_at > new Date((+new Date()) - 24 * 3600 * 1000).toISOString()) { + continue; + } + + console.warn("deleting old reminder comment", comment.id, "from PR", pr.number, 'dated', comment.created_at); + + await octokit.request( + "DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}", + { + repo: "BlueWallet", + owner: "BlueWallet", + comment_id: comment.id, + } + ); + } + } + // end comments cleanup + const _requestedReviewers = {}; const requestedReviews = await octokit.request("GET /repos/{owner}/{repo}/pulls/{ref}/requested_reviewers", { diff --git a/src/main.ts b/src/main.ts index ecc58f1..4d629e6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,3 @@ -import * as core from "@actions/core"; import * as github from "@actions/github"; const token = process.env.TOKEN;