|
38 | 38 |
|
39 | 39 | - name: Get second to latest run time |
40 | 40 | env: |
41 | | - GH_TOKEN: ${{ secrets.MACHINE_ACCOUNT_PAT }} |
| 41 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
42 | 42 | run: | |
43 | 43 | OUTPUT=$(gh run list --workflow sync_translations.yml --json updatedAt | jq -r '.[1].updatedAt') |
44 | 44 | echo "LATEST_RUN=$OUTPUT" >> $GITHUB_ENV |
@@ -88,27 +88,43 @@ jobs: |
88 | 88 | cd ./tools/localization |
89 | 89 | yarn start update |
90 | 90 | |
91 | | - - name: Commit changes |
92 | | - run: | |
93 | | - git add docs/marketing/localized_description AnkiDroid/src/main/res |
94 | | - git commit -am 'Updated strings from Crowdin' |
95 | | - git push --set-upstream origin +i18n_sync |
96 | | - echo "The results of the sync are on the i18n_sync branch, PR them from there for merge." |
97 | | - echo "https://github.com/ankidroid/Anki-Android/compare/i18n_sync?expand=1" |
98 | | -
|
99 | | - - name: Check if there are strings changes |
| 91 | + - name: Check for changes and handle Neutral result |
100 | 92 | id: tr_check |
101 | | - run: | |
102 | | - git checkout i18n_sync |
103 | | - COMMITS_COUNT=`git rev-list --count HEAD ^main` |
104 | | - if [ "$COMMITS_COUNT" -gt 0 ]; then |
105 | | - echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT |
106 | | - else |
107 | | - echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT |
108 | | - fi |
| 93 | + uses: actions/github-script@v7 |
| 94 | + with: |
| 95 | + script: | |
| 96 | + const { execSync } = require('child_process'); |
| 97 | + |
| 98 | + execSync('git add docs/marketing/localized_description AnkiDroid/src/main/res'); |
| 99 | + |
| 100 | + const status = execSync('git diff --cached --name-only').toString().trim(); |
| 101 | + |
| 102 | + if(!status) { |
| 103 | + console.log("No changes detected. Setting status to neutral."); |
| 104 | + |
| 105 | + await github.rest.checks.create({ |
| 106 | + owner: context.repo.owner, |
| 107 | + repo: context.repo.repo, |
| 108 | + name: 'Sync Translations with Crowdin', |
| 109 | + head_sha: context.sha, |
| 110 | + status: 'completed', |
| 111 | + conclusion: 'neutral', |
| 112 | + output: { |
| 113 | + title: 'Translation Sync', |
| 114 | + summary: 'No translation changes were found on Crowdin to sync' |
| 115 | + } |
| 116 | + }); |
| 117 | + |
| 118 | + core.setOutput('HAS_CHANGES', 'false'); |
| 119 | + } else { |
| 120 | + core.setOutput('HAS_CHANGES', 'true'); |
| 121 | + execSync("git commit -m 'Updated strings from Crowdin'"); |
| 122 | + execSync("git push --set-upstream origin +i18n_sync"); |
| 123 | + console.log("Changes pushed to i18n_sync branch"); |
| 124 | + } |
109 | 125 |
|
110 | 126 | - name: Create PR for strings changes if needed |
111 | | - if: ${{ steps.tr_check.outputs.HAS_CHANGES }} |
| 127 | + if: steps.tr_check.outputs.HAS_CHANGES == 'true' |
112 | 128 | uses: actions/github-script@v9 |
113 | 129 | with: |
114 | 130 | github-token: ${{ secrets.MACHINE_ACCOUNT_PAT }} |
|
0 commit comments