Просмотр исходного кода

:sparkles: Ask company submissions for a pricing page link

Jeff Triplett 2 дней назад
Родитель
Сommit
b99955b5d1
2 измененных файлов с 11 добавлено и 2 удалено
  1. 5 1
      .github/scripts/check-pr-template.js
  2. 6 1
      .github/workflows/pr-template.yml

+ 5 - 1
.github/scripts/check-pr-template.js

@@ -59,7 +59,11 @@ function checkTemplate(body) {
 
   const company = /^\s*-\s*\[x\].*on behalf of a company/im.test(authorship || "");
 
-  return { missing, company };
+  // Question 5 is optional: it asks paid products for a public pricing page.
+  const pricing = section(criteria, /^\s*5\.\s+\*\*.*?\*\*/m, /^\s*6\.\s+\*\*|^----|^## /m);
+  const hasPricing = /https?:\/\//i.test((pricing || "").replace(/_\(.*?\)_/gs, ""));
+
+  return { missing, company, hasPricing };
 }
 
 module.exports = { checkTemplate };

+ 6 - 1
.github/workflows/pr-template.yml

@@ -51,7 +51,7 @@ jobs:
                 core.info(`#${issue_number}: skipped (${pr.user.login})`);
                 return;
               }
-              const { missing, company } = checkTemplate(pr.body);
+              const { missing, company, hasPricing } = checkTemplate(pr.body);
               const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 });
               const existing = comments.find((c) => c.body && c.body.includes(MARKER));
 
@@ -104,6 +104,11 @@ jobs:
                   `\n\nThis submission is on behalf of a company. Please read the ` +
                   `[commercial products and services](https://github.com/${owner}/${repo}/blob/main/contributing.md#commercial-products-and-services) ` +
                   `section of the contribution guidelines.`;
+                if (!hasPricing) {
+                  note +=
+                    `\n\nIf this is a paid product, please add a link to your public pricing page under ` +
+                    `question 5 of the template, or a short note on how it is priced.`;
+                }
               }
               if (existing || company) await say(note);
             }