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
47 changes: 47 additions & 0 deletions .github/workflows/check-pr-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Check PR size

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check_pr_size:
runs-on: ubuntu-latest
timeout-minutes: 1

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Calculate changed lines
id: diff_check
run: |
# Get the target branch commit (base) and the PR branch commit (head)
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
echo "Base SHA: $BASE_SHA"
echo "Head SHA: $HEAD_SHA"

# Compute the merge base between the two branches
MERGE_BASE=$(git merge-base "$HEAD_SHA" "$BASE_SHA")
echo "Merge Base: $MERGE_BASE"

# Calculate added and deleted lines between the merge base and the head commit
TOTAL_CHANGED=$(git diff --numstat "$MERGE_BASE" "$HEAD_SHA" \
| awk '{ added += $1; deleted += $2 } END { print added + deleted }')

# Default to 0 if nothing is output
TOTAL_CHANGED=${TOTAL_CHANGED:-0}
echo "Total changed lines: $TOTAL_CHANGED"

# Make the total available for later steps
echo "total=$TOTAL_CHANGED" >> "$GITHUB_OUTPUT"

- name: Fail if too many changes
if: ${{ steps.diff_check.outputs.total > 500 }}
run: |
echo "PR has ${{ steps.diff_check.outputs.total }} changed lines, which exceeds the 500-line limit."
echo "Please reduce the size of this PR."
exit 1
29 changes: 29 additions & 0 deletions .github/workflows/stale-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Mark stale PRs

on:
schedule:
- cron: "0 7 * * *"
workflow_dispatch:

permissions:
issues: write
pull-requests: write

jobs:
stale_prs:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30
days-before-close: 15
stale-pr-message: "This pull request has been inactive for 30 days. Is it still in progress? If so, please leave a comment or make an update to keep it open. Otherwise, it will be closed automatically in 15 days."
close-pr-message: "This pull request was closed automatically due to prolonged inactivity."
# Labels
stale-pr-label: stalled
exempt-draft-pr: true
# Do not touch issues
days-before-issue-stale: -1
days-before-issue-close: -1