-
-
Notifications
You must be signed in to change notification settings - Fork 117
71 lines (60 loc) · 2.26 KB
/
i18n-automerge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: i18n PR auto-merge
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
workflow_dispatch:
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
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Count lines changed
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
# Debug: Show the base and head SHA
echo "Base SHA: $BASE_SHA"
echo "Head SHA: $HEAD_SHA"
# Check if the commits exist
if ! git cat-file -e $BASE_SHA || ! git cat-file -e $HEAD_SHA; then
echo "ERROR: One or both of the commits are not available."
exit 1
fi
# Calculate the total number of lines changed (added, removed, or modified)
LINES_CHANGED=$(git diff --shortstat $BASE_SHA $HEAD_SHA | awk '{print $4 + $6 + $8}')
if [ -z "$LINES_CHANGED" ]; then
LINES_CHANGED=0
fi
echo "Total lines changed: $LINES_CHANGED"
# Check if the number of lines changed is more than 50
if [ "$LINES_CHANGED" -le 50 ]; then
echo "ERROR: 50 or fewer lines have been changed. Failing the check."
exit 1
else
echo "Success: More than 50 lines have been changed."
node scripts/catalogs.js
if git diff --quiet src/data/catalogs.json; then
echo "No changes to catalogs.json"
else
echo "Changes to catalogs.json"
git add src/data/catalogs.json
git commit -m "Update catalogs.json"
git push
fi
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 }}