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

Condition check for no content in PR #3304

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Changes from all commits
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
28 changes: 16 additions & 12 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
permissions:
contents: read
pull-requests: write

steps:
- name: Label PR
uses: actions/github-script@v4
Expand All @@ -43,18 +42,23 @@ jobs:
};
const prBody = context.payload.pull_request.body;
const prLabels = [];
const regex = /^\s*\/kind\s+(.+)$/m;
const match = prBody.match(regex);
console.log(`PR body: '${prBody}'`);
console.log(`Regex match: '${match}'`);
if (match && match[1] in keywords) {
const keyword = match[1];
const label = keywords[keyword];
console.log(`Adding label: '${label}' based on keyword '${keyword}'`);
prLabels.push(label);
} else {
console.log(`Adding label: 'kind/other' as no matching keyword found.`);
if (prBody === null || prBody.trim() === "") {
console.log("Pull Request body is empty");
prLabels.push("kind/other");
} else {
const regex = /^\s*\/kind\s+(.+)$/m;
const match = prBody.match(regex);
console.log(`PR body: '${prBody}'`);
console.log(`Regex match: '${match}'`);
if (match && match[1] in keywords) {
const keyword = match[1];
const label = keywords[keyword];
console.log(`Adding label: '${label}' based on keyword '${keyword}'`);
prLabels.push(label);
} else {
console.log(`Adding label: 'kind/other' as no matching keyword found.`);
prLabels.push("kind/other");
}
}
try {
github.issues.addLabels({
Expand Down
Loading