Skip to content

Commit 45a4ae9

Browse files
committed
improving sync when no pr is necessary
1 parent 7defb30 commit 45a4ae9

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

.github/workflows/sync_translations.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
timeout-minutes: 50
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
- uses: actions/checkout@v6
2121
with:
2222
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
2323
ref: 'main'
@@ -45,7 +45,7 @@ jobs:
4545
4646
- name: Calculate seconds passed
4747
id: calc_time
48-
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
48+
uses: actions/github-script@v8
4949
with:
5050
script: |
5151
const lastRun = new Date(process.env.LATEST_RUN);
@@ -58,7 +58,7 @@ jobs:
5858
if: steps.calc_time.outputs.time_left > 0
5959
run: sleep ${{ steps.calc_time.outputs.time_left }}
6060

61-
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
61+
- uses: actions/setup-node@v6
6262
with:
6363
node-version: 20
6464

@@ -88,28 +88,30 @@ jobs:
8888
cd ./tools/localization
8989
yarn start update
9090
91-
- name: Commit changes
91+
- name: Check for changes
92+
id: tr_check
9293
run: |
9394
git add docs/marketing/localized_description AnkiDroid/src/main/res
94-
git commit -am 'Updated strings from Crowdin'
95+
if git diff --cached --quiet; then
96+
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
97+
else
98+
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
99+
fi
100+
101+
- name: Commit and Push changes
102+
if: steps.tr_check.outputs.HAS_CHANGES == 'true'
103+
run: |
104+
git commit -m 'Updated strings from Crowdin'
95105
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"
98106
99-
- name: Check if there are strings changes
100-
id: tr_check
107+
- name: Update Summary
108+
if: steps.tr_check.outputs.HAS_CHANGES == 'false'
101109
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
110+
echo "Translation Sync Result: No new translation found on Crowdin. No Pull Request necessary" >> $GITHUB_STEP_SUMMARY
109111
110112
- name: Create PR for strings changes if needed
111-
if: ${{ steps.tr_check.outputs.HAS_CHANGES }}
112-
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
113+
if: steps.tr_check.outputs.HAS_CHANGES == 'true'
114+
uses: actions/github-script@v9
113115
with:
114116
github-token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
115117
script: |

0 commit comments

Comments
 (0)