Skip to content

chore(deps): bump the all-actions group across 1 directory with 3 updates #89

chore(deps): bump the all-actions group across 1 directory with 3 updates

chore(deps): bump the all-actions group across 1 directory with 3 updates #89

Workflow file for this run

name: PR Quality Checks
on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
branches: [master]
jobs:
size-label:
name: Size Labeler
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Fetch head commit
run: |
git fetch ${{ github.event.pull_request.head.repo.clone_url }} ${{ github.event.pull_request.head.ref }}
- name: Calculate changed lines
id: changed-lines
run: |
DIFF_DATA=$(git diff --shortstat origin/${{ github.event.pull_request.base.ref }}..FETCH_HEAD)
ADDED=$(echo "$DIFF_DATA" | grep -o '[0-9]\+ insertions' | grep -o '[0-9]\+' || true)
DELETED=$(echo "$DIFF_DATA" | grep -o '[0-9]\+ deletions' | grep -o '[0-9]\+' || true)
ADDED=${ADDED:-0}
DELETED=${DELETED:-0}
TOTAL_LINES=$((ADDED + DELETED))
echo "changed_lines=${TOTAL_LINES}" >> $GITHUB_OUTPUT
echo "Lines changed: $TOTAL_LINES"
- name: Apply size label
uses: actions/github-script@v9
env:
CHANGES: ${{ steps.changed-lines.outputs.changed_lines }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const changeCount = parseInt(process.env.CHANGES);
const size =
changeCount <= 9 ? 'XS' :
changeCount <= 49 ? 'S' :
changeCount <= 199 ? 'M' :
changeCount <= 499 ? 'L' : 'XL';
console.log(`Determined size label: size-${size}`);
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const sizeLabels = labels.data.filter(label =>
label.name.startsWith('size-')
);
for (const label of sizeLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: label.name
});
}
try {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: `size-${size}`,
color: '0e8a16',
description: `Size label for PR with ${changeCount} lines changed`
});
} catch (error) {
if (error.status !== 422) throw error;
console.log('Label already exists, skipping creation');
}
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [`size-${size}`]
});
console.log('Size label based on lines changed applied');
check-merge-commits:
name: Merge Commit Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Detect Merge Commits
run: |
if git log --merges ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --pretty=format:"%h" | grep -q .; then
echo "::error::PR contains merge commits. Use rebase instead."
exit 1
else
echo "No merge commits detected."
fi