Skip to content

Commit

Permalink
feat: set no-notes automatically on build PRs (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored Sep 17, 2024
1 parent f7b6f47 commit bbe17bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"devDependencies": {
"@types/bunyan": "^1.8.6",
"@types/debug": "^4.1.12",
"@types/jest": "^29.0.3",
"@types/node": "^16.11.7",
"debug": "^4.3.4",
Expand All @@ -18,7 +19,7 @@
"lint-staged": "^13.0.4",
"prettier": "^2.7.1",
"ts-jest": "^29.0.1",
"typescript": "^4.8.2"
"typescript": "^5.6.2"
},
"scripts": {
"build": "tsc",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const NO_NOTES_BODY = '**No Release Notes**';
export const NOTES_LEAD = '**Release Notes Persisted**';
export const SEMANTIC_BUILD_PREFIX = 'build:';
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { PullRequest } from '@octokit/webhooks-types/schema';
import { Probot, Context } from 'probot';

import * as noteUtils from './note-utils';

import d from 'debug';
import { SEMANTIC_BUILD_PREFIX } from './constants';
const debug = d('note-utils');

const submitFeedbackForPR = async (
context: Context<'pull_request'>,
pr: any,
pr: PullRequest,
shouldComment = false,
) => {
const releaseNotes = noteUtils.findNoteInPRBody(pr.body);
const releaseNotes = pr.body && noteUtils.findNoteInPRBody(pr.body);
const github = context.octokit;

if (!releaseNotes) {
Expand All @@ -24,6 +27,17 @@ const submitFeedbackForPR = async (
return;
}

if (pr.title.startsWith(SEMANTIC_BUILD_PREFIX)) {
debug("Adding 'Notes: none' to build: PR body");
await github.pulls.update(
context.repo({
pull_number: pr.number,
body: pr.body + '\n\n---\n\nNotes: none',
}),
);
return;
}

debug(`No Release Notes: posting failed check.`);
await github.repos.createCommitStatus(
context.repo({
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"sourceMap": true,
"rootDir": "src",
"experimentalDecorators": true,
"allowJs": true,
"strict": true,
"allowSyntheticDefaultImports": true
},
"include": [
Expand Down
20 changes: 16 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,13 @@
dependencies:
"@types/node" "*"

"@types/debug@^4.1.12":
version "4.1.12"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
integrity sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==
dependencies:
"@types/ms" "*"

"@types/express-serve-static-core@^4.17.18":
version "4.17.31"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz#a1139efeab4e7323834bb0226e62ac019f474b2f"
Expand Down Expand Up @@ -1269,6 +1276,11 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10"
integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==

"@types/ms@*":
version "0.7.34"
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.34.tgz#10964ba0dee6ac4cd462e2795b6bebd407303433"
integrity sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==

"@types/node@*", "@types/node@>= 8":
version "14.0.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.4.tgz#43a63fc5edce226bed106b31b875165256271107"
Expand Down Expand Up @@ -4194,10 +4206,10 @@ type-is@~1.6.18:
media-typer "0.3.0"
mime-types "~2.1.24"

typescript@^4.8.2:
version "4.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88"
integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==
typescript@^5.6.2:
version "5.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.2.tgz#d1de67b6bef77c41823f822df8f0b3bcff60a5a0"
integrity sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==

uglify-js@^3.1.4:
version "3.9.3"
Expand Down

0 comments on commit bbe17bb

Please sign in to comment.