From a6d6257134eac6c3ae9015cb252dd7fdae409ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKirti?= <“119587+kirti@users.noreply.github.com”> Date: Sat, 21 Mar 2026 18:58:21 -0400 Subject: [PATCH 1/5] Add PR checks --- Simple-Node.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simple-Node.md b/Simple-Node.md index fb81b32..87fc273 100644 --- a/Simple-Node.md +++ b/Simple-Node.md @@ -98,4 +98,4 @@ Steps execute sequentially within a job: If any step fails, subsequent steps are skipped and the workflow fails. ---- \ No newline at end of file +--- From ad12c5e78e8005d75b75c7da367d3f60a10eedad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKirti?= <“119587+kirti@users.noreply.github.com”> Date: Sat, 21 Mar 2026 19:13:23 -0400 Subject: [PATCH 2/5] codewonser added --- .github/CODEOWNERS | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..9e331b7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# kirti owns everything +* @kirti + +# Specific ownership +/.github/workflows/ @kirti +/src/ @kirti +*.md @kirti \ No newline at end of file From 9d1185e81064d0d95d359e7b8113173389d8feb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKirti?= <“119587+kirti@users.noreply.github.com”> Date: Sat, 21 Mar 2026 19:18:49 -0400 Subject: [PATCH 3/5] codewonser added --- package.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package.json b/package.json index f50c794..9cd5de3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,20 @@ "version": "0.1.0", "private": true, "homepage": "https://kirti.github.io/github-actions-practice", + "contributors": [ + "Kirti <119587+kirti@users.noreply.github.com>" + ], + "maintainers": [ + "Kirti <119587+kirti@users.noreply.github.com>" + ], + "repository": { + "type": "git", + "url": "https://github.com/kirti/github-actions-practice.git" + }, + "bugs": { + "url": "https://github.com/kirti/github-actions-practice/issues", + "email": "119587+kirti@users.noreply.github.com" + }, "dependencies": { "@testing-library/dom": "^10.4.1", "@testing-library/jest-dom": "^6.9.1", From c1de55f630e174cd31a783bc932c5a2d2f401ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKirti?= <“119587+kirti@users.noreply.github.com”> Date: Sat, 21 Mar 2026 19:20:52 -0400 Subject: [PATCH 4/5] codewonser added --- package.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index 9cd5de3..c33a8dc 100644 --- a/package.json +++ b/package.json @@ -3,20 +3,11 @@ "version": "0.1.0", "private": true, "homepage": "https://kirti.github.io/github-actions-practice", - "contributors": [ - "Kirti <119587+kirti@users.noreply.github.com>" - ], - "maintainers": [ - "Kirti <119587+kirti@users.noreply.github.com>" - ], + "author": "Kirti", "repository": { "type": "git", "url": "https://github.com/kirti/github-actions-practice.git" }, - "bugs": { - "url": "https://github.com/kirti/github-actions-practice/issues", - "email": "119587+kirti@users.noreply.github.com" - }, "dependencies": { "@testing-library/dom": "^10.4.1", "@testing-library/jest-dom": "^6.9.1", From 086d20bc273181ca5e306297443f65e410537a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKirti?= <“119587+kirti@users.noreply.github.com”> Date: Sat, 21 Mar 2026 20:12:56 -0400 Subject: [PATCH 5/5] Fix PR automation YAML syntax errors --- .github/workflows/pr-automation.yml | 226 ++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 .github/workflows/pr-automation.yml diff --git a/.github/workflows/pr-automation.yml b/.github/workflows/pr-automation.yml new file mode 100644 index 0000000..215a861 --- /dev/null +++ b/.github/workflows/pr-automation.yml @@ -0,0 +1,226 @@ +name: PR Automation + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + # Job 1: Auto-label based on files changed + auto-label: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Label based on files changed + uses: actions/github-script@v7 + with: + script: | + const { data: files } = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }); + + const labels = new Set(); + + for (const file of files) { + const path = file.filename; + + if (path.includes('.github/workflows/')) { + labels.add('workflows'); + } + + if (path.startsWith('src/')) { + labels.add('source-code'); + } + + if (path.includes('.test.') || path.includes('.spec.')) { + labels.add('tests'); + } + + if (path.endsWith('.md')) { + labels.add('documentation'); + } + + if (path === 'package.json' || path === 'package-lock.json') { + labels.add('dependencies'); + } + + if (path.endsWith('.css') || path.endsWith('.scss')) { + labels.add('styles'); + } + + if (path.includes('components/')) { + labels.add('components'); + } + } + + if (labels.size > 0) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: Array.from(labels) + }); + } + + # Job 2: Check PR size and add size label + size-label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Check PR size + uses: actions/github-script@v7 + with: + script: | + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }); + + const additions = pr.additions; + const deletions = pr.deletions; + const totalChanges = additions + deletions; + + let sizeLabel = 'size/XS'; + + if (totalChanges >= 1000) { + sizeLabel = 'size/XL'; + } else if (totalChanges >= 500) { + sizeLabel = 'size/L'; + } else if (totalChanges >= 200) { + sizeLabel = 'size/M'; + } else if (totalChanges >= 50) { + sizeLabel = 'size/S'; + } + + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + for (const label of labels) { + if (label.name.startsWith('size/')) { + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: label.name + }).catch(() => {}); + } + } + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: [sizeLabel] + }).catch(() => {}); + + # Job 3: Comment with PR statistics + pr-stats: + runs-on: ubuntu-latest + needs: size-label + permissions: + pull-requests: write + + steps: + - name: Comment PR with stats + uses: actions/github-script@v7 + with: + script: | + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }); + + const { data: files } = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }); + + const additions = pr.additions; + const deletions = pr.deletions; + const changedFiles = pr.changed_files; + const totalChanges = additions + deletions; + + let size = 'XS'; + if (totalChanges >= 1000) { + size = 'XL'; + } else if (totalChanges >= 500) { + size = 'L'; + } else if (totalChanges >= 200) { + size = 'M'; + } else if (totalChanges >= 50) { + size = 'S'; + } + + const fileTypes = {}; + for (const file of files) { + const ext = file.filename.split('.').pop(); + fileTypes[ext] = (fileTypes[ext] || 0) + 1; + } + + const fileTypesStr = Object.entries(fileTypes) + .sort((a, b) => b[1] - a[1]) + .slice(0, 5) + .map(([ext, count]) => `- ${ext}: ${count} files`) + .join('\n'); + + let recommendation = 'Great! This PR is easy to review.'; + if (totalChanges >= 500) { + recommendation = 'Large PR! Consider splitting into smaller PRs for easier review.'; + } else if (totalChanges >= 200) { + recommendation = 'Medium-sized PR. Consider breaking it down if possible.'; + } + + const commentBody = '## PR Statistics - Size: ' + size + '\n\n' + + '**Total Changes:** ' + totalChanges + ' lines\n\n' + + '### Changes\n' + + '- Additions: ' + additions + ' lines\n' + + '- Deletions: ' + deletions + ' lines\n' + + '- Files changed: ' + changedFiles + '\n\n' + + '### File Types\n' + + fileTypesStr + '\n\n' + + '### Review Recommendations\n' + + recommendation + '\n\n' + + '---\n' + + '*Automated by PR Automation*'; + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const botComment = comments.find(comment => + comment.user.type === 'Bot' && + comment.body.includes('PR Statistics') + ); + + if (botComment) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: commentBody + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: commentBody + }); + }