Member-only story
Day 5 — PR Automation: Auto-Labels, Size Checks, and Statistics
Reviewing pull requests is easier when you can see at a glance what changed and how large the PR is.
Day 5 automates three things
labelling PRs based on which files changed,
adding a size label, and
posting a statistics comment.
WorkFlow
Three separate jobs running in parallel on every PR.
Job 1 — Auto-label by file type
```yaml
- name: Label based on files changed
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({...});
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.')) labels.add('tests');
if (path.endsWith('.md')) labels.add('documentation');
if (path === 'package.json') labels.add('dependencies');
if (path.endsWith('.css')) labels.add('styles');
if (path.includes('components/')) labels.add('components');
}
if…









