Skip to content

Commit

Permalink
test: commnet on large PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
casswedson committed Apr 6, 2024
1 parent 7fece1f commit d22d964
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/size-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Sort large PRs

on:
pull_request_target:
branches:
- master
# TODO: make this work on synchronize, be smart about don't spam with
# warning message each push
types: [opened]
paths:
- 'data/**.json'
- '**.cpp'
- '**.h'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}

jobs:
changed_files:
runs-on: ubuntu-latest
name: Post warning
steps:
- uses: actions/checkout@v4

- name: calculate changes
id: lines_changed
run: |
git remote add upstream https://github.com/CleverRaven/Cataclysm-DDA.git
git fetch --depth=1 upstream master
json_changed=$(git diff --numstat --ignore-blank-lines upstream/master -- 'data/**/*.json' | awk '{sum=$1+$2} END{print sum}')
echo "Debug: lines of data/*.json added or deleted: $json_changed"
cpp_changed=$(git diff --numstat --ignore-blank-lines upstream/master -- '**/*.cpp' '**/*.h' | awk '{sum=$1+$2} END{print sum}')
echo "Debug: lines of *.cpp and *.h added or deleted: $cpp_changed"
echo "json_changed=$json_changed" >> $GITHUB_OUTPUT
echo "cpp_changed=$cpp_changed" >> $GITHUB_OUTPUT
- if: ${{ steps.lines_changed.outputs.json_changed > 1000 || steps.lines_changed.outputs.cpp_changed > 300 }}
run: |
gh pr comment "$PR_NUMBER" --body "This is a large PR! Merging has been blocked until one of the project leads can take a look and approve it. This is a safety feature to prevent changes from being merged that would be immediately reverted."

0 comments on commit d22d964

Please sign in to comment.