Skip to content

chore(deps-dev): bump the aws-sdk group across 1 directory with 2 updates #142

chore(deps-dev): bump the aws-sdk group across 1 directory with 2 updates

chore(deps-dev): bump the aws-sdk group across 1 directory with 2 updates #142

Workflow file for this run

name: PR Size Check
on:
pull_request_target:
branches: [main]
permissions:
pull-requests: write
jobs:
label-size:
runs-on: ubuntu-latest
steps:
- name: Calculate PR size and apply label
uses: actions/github-script@v9
with:
script: |
const prNumber = context.payload.pull_request.number;
const { owner, repo } = context.repo;
const files = await github.paginate(github.rest.pulls.listFiles, {
owner, repo, pull_number: prNumber, per_page: 100,
});
// Exclude generated/lock files from the count
const EXCLUDED = [
/package-lock\.json$/,
/\.snap$/,
/examples\/.*\.json$/, // example workflows are essentially fixtures
];
let total = 0;
for (const file of files) {
if (EXCLUDED.some((re) => re.test(file.filename))) continue;
total += file.additions + file.deletions;
}
const existing = await github.rest.issues.listLabelsOnIssue({
owner, repo, issue_number: prNumber,
});
for (const label of existing.data) {
if (label.name.startsWith('size/')) {
try {
await github.rest.issues.removeLabel({
owner, repo, issue_number: prNumber, name: label.name,
});
} catch (e) {
if (e.status !== 404) throw e;
}
}
}
let sizeLabel;
if (total <= 20) sizeLabel = 'size/xs';
else if (total <= 100) sizeLabel = 'size/s';
else if (total <= 500) sizeLabel = 'size/m';
else if (total <= 1000) sizeLabel = 'size/l';
else sizeLabel = 'size/xl';
const COLORS = {
'size/xs': '3CBF00', 'size/s': '5D9801',
'size/m': 'FBCA04', 'size/l': 'E67409', 'size/xl': 'D93F0B',
};
try {
await github.rest.issues.getLabel({ owner, repo, name: sizeLabel });
} catch (e) {
if (e.status === 404) {
await github.rest.issues.createLabel({
owner, repo, name: sizeLabel,
color: COLORS[sizeLabel],
description: `PR size: ${sizeLabel.split('/')[1].toUpperCase()}`,
});
} else { throw e; }
}
await github.rest.issues.addLabels({
owner, repo, issue_number: prNumber, labels: [sizeLabel],
});
core.info(`${total} changed lines -> ${sizeLabel}`);
if (sizeLabel === 'size/xl') {
core.warning(`PR is large (${total} lines). Consider splitting.`);
}