diff --git a/.github/workflows/i18n-automerge.yml b/.github/workflows/i18n-automerge.yml index 79f47399..06526f76 100644 --- a/.github/workflows/i18n-automerge.yml +++ b/.github/workflows/i18n-automerge.yml @@ -18,14 +18,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm ci - - - name: Merge PR if there are significant changes - run: | + - run: | BASE_SHA="${{ github.event.pull_request.base.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 if [ "$LINES_CHANGED" -le 50 ]; then - echo "ERROR: 50 or fewer lines have been changed. Failing the check." exit 0 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 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 + echo "More than 50 lines have been changed. Merging pull request." + PR_NUMBER=$(echo ${{ github.event.pull_request.number }}) + gh pr merge $PR_NUMBER --auto --squash fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-catalogs.yml b/.github/workflows/update-catalogs.yml new file mode 100644 index 00000000..583d07f1 --- /dev/null +++ b/.github/workflows/update-catalogs.yml @@ -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