Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function checkPRForCompletedChecklist(expectedNumberOfChecklistItems: number, ch

async function generateDynamicChecksAndCheckForCompletion() {
// Generate dynamic checks
console.log('Generating dynamic checks...');
const dynamicChecks = await getChecklistCategoriesForPullRequest();
let isPassing = true;
let didChecklistChange = false;
Expand All @@ -91,13 +92,15 @@ async function generateDynamicChecksAndCheckForCompletion() {
const regex = new RegExp(`- \\[([ x])] ${escapeRegExp(check)}`);
const match = regex.exec(checklist);
if (!match) {
console.log('Adding check to the checklist:', check);
// Add it to the PR body
isPassing = false;
checklist += `- [ ] ${check}\r\n`;
didChecklistChange = true;
} else {
const isChecked = match[1] === 'x';
if (!isChecked) {
console.log('Found unchecked checklist item:', check);
isPassing = false;
}
}
Expand All @@ -112,6 +115,7 @@ async function generateDynamicChecksAndCheckForCompletion() {
const match = regex.exec(checklist);
if (match) {
// Remove it from the PR body
console.log('Check has been removed from the checklist:', check);
checklist = checklist.replace(match[0], '');
didChecklistChange = true;
}
Expand All @@ -123,6 +127,7 @@ async function generateDynamicChecksAndCheckForCompletion() {

// Update the PR body
if (didChecklistChange) {
console.log('Checklist changed, updating PR...');
await GithubUtils.octokit.pulls.update({
owner: CONST.GITHUB_OWNER,
repo: CONST.APP_REPO,
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21574,6 +21574,7 @@ function checkPRForCompletedChecklist(expectedNumberOfChecklistItems, checklist)
}
async function generateDynamicChecksAndCheckForCompletion() {
// Generate dynamic checks
console.log('Generating dynamic checks...');
const dynamicChecks = await getChecklistCategoriesForPullRequest();
let isPassing = true;
let didChecklistChange = false;
Expand All @@ -21585,6 +21586,7 @@ async function generateDynamicChecksAndCheckForCompletion() {
const regex = new RegExp(`- \\[([ x])] ${(0, escapeRegExp_1.default)(check)}`);
const match = regex.exec(checklist);
if (!match) {
console.log('Adding check to the checklist:', check);
// Add it to the PR body
isPassing = false;
checklist += `- [ ] ${check}\r\n`;
Expand All @@ -21593,6 +21595,7 @@ async function generateDynamicChecksAndCheckForCompletion() {
else {
const isChecked = match[1] === 'x';
if (!isChecked) {
console.log('Found unchecked checklist item:', check);
isPassing = false;
}
}
Expand All @@ -21605,6 +21608,7 @@ async function generateDynamicChecksAndCheckForCompletion() {
const match = regex.exec(checklist);
if (match) {
// Remove it from the PR body
console.log('Check has been removed from the checklist:', check);
checklist = checklist.replace(match[0], '');
didChecklistChange = true;
}
Expand All @@ -21614,6 +21618,7 @@ async function generateDynamicChecksAndCheckForCompletion() {
const newBody = contentBeforeChecklist + checklistStartsWith + checklist + checklistEndsWith + contentAfterChecklist;
// Update the PR body
if (didChecklistChange) {
console.log('Checklist changed, updating PR...');
await GithubUtils_1.default.octokit.pulls.update({
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/authorChecklist.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: PR Author Checklist

on:
pull_request:
# We use pull_request_target here so that the GitHub token will have read/write access and be able to modify the PR description if needed.
# Warning: – when using the pull_request_target event, DO NOT checkout code from an untrusted branch: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
pull_request_target:
types: [opened, edited, reopened, synchronize]

jobs:
Expand All @@ -16,4 +18,4 @@ jobs:
- name: authorChecklist.js
uses: ./.github/actions/javascript/authorChecklist
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}