Split the workflows

Too many commands are hard to debug
This commit is contained in:
Lim Chee Aun 2024-08-19 22:39:18 +08:00
parent f291d33ab0
commit 876480f87e
2 changed files with 36 additions and 24 deletions

View file

@ -18,14 +18,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- run: |
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Merge PR if there are significant changes
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}" BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}" HEAD_SHA="${{ github.event.pull_request.head.sha }}"
@ -50,24 +43,11 @@ jobs:
# Check if the number of lines changed is more than 50 # Check if the number of lines changed is more than 50
if [ "$LINES_CHANGED" -le 50 ]; then if [ "$LINES_CHANGED" -le 50 ]; then
echo "ERROR: 50 or fewer lines have been changed. Failing the check."
exit 0 exit 0
else else
echo "Success: More than 50 lines have been changed." echo "More than 50 lines have been changed. Merging pull request."
node scripts/catalogs.js PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
if git diff --quiet src/data/catalogs.json; then gh pr merge $PR_NUMBER --auto --squash
echo "No changes to catalogs.json"
else
echo "Changes to catalogs.json"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add src/data/catalogs.json
git commit -m "Update catalogs.json"
git push origin HEAD:l10n_main
echo "Merging pull request"
PR_NUMBER=$(echo ${{ github.event.pull_request.number }})
gh pr merge $PR_NUMBER --auto --squash
fi
fi fi
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

32
.github/workflows/update-catalogs.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Update catalogs
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'src/locales/**'
jobs:
update-catalogs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Update catalogs.json
run: |
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 config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add src/data/catalogs.json
git commit -m "Update catalogs.json"
git push origin HEAD:main
fi