2024-08-18 12:40:24 +03:00
|
|
|
name: i18n PR auto-merge
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [opened, synchronize, reopened, labeled]
|
2024-08-18 12:49:28 +03:00
|
|
|
workflow_dispatch:
|
2024-08-18 12:40:24 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
run-and-merge:
|
|
|
|
if: contains(github.event.pull_request.labels.*.name, 'i18n') &&
|
|
|
|
github.event.pull_request.base.ref == 'main' &&
|
|
|
|
github.event.pull_request.head.ref == 'l10n_main'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Count lines changed
|
|
|
|
run: |
|
|
|
|
# Calculate the total number of lines changed (added, removed, or modified)
|
|
|
|
LINES_CHANGED=$(git diff --shortstat ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | awk '{print $4 + $6 + $8}')
|
|
|
|
echo "Total lines changed: $LINES_CHANGED"
|
|
|
|
|
|
|
|
# Check if the number of lines changed is more than 20
|
|
|
|
if [ "$LINES_CHANGED" -le 20 ]; then
|
|
|
|
echo "ERROR: 20 or fewer lines have been changed. Failing the check."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success: More than 20 lines have been changed."
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Merge pull request
|
|
|
|
if: ${{ success() }}
|
|
|
|
run: |
|
|
|
|
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
|
|
|
|
gh pr merge $PR_NUMBER --auto --squash
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|