1414 environment : transifex
1515 steps :
1616 - uses : actions/checkout@v4
17+ - name : Setup i18n-sync branch
18+ run : |
19+ # Fetch i18n-sync branch if it exists remotely
20+ if git ls-remote --exit-code --heads origin i18n-sync; then
21+ git fetch origin i18n-sync:i18n-sync
22+ git checkout i18n-sync
23+ else
24+ # Create new branch from main
25+ git checkout -b i18n-sync
26+ fi
1727 - name : Install Transifex client
1828 run : |
1929 curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
@@ -27,76 +37,116 @@ jobs:
2737 # --minimum-perc 40: only pulls files that are at least 40% translated
2838 # Empty strings will fallback to English at runtime via browser.i18n
2939 ./tx --token "${{ secrets.TX_TOKEN }}" pull --all --force --mode onlytranslated --minimum-perc 40
30- - uses : stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
31- with :
32- # Optional. Commit message for the created commit.
33- # Defaults to "Apply automatic changes"
34- commit_message : " chore: pull transifex translations"
35-
36- # Optional. Local and remote branch name where commit is going to be pushed
37- # to. Defaults to the current branch.
38- # You might need to set `create_branch: true` if the branch does not exist.
39- branch : i18n-sync
40-
41- # Optional. Options used by `git-commit`.
42- # See https://git-scm.com/docs/git-commit#_options
43- commit_options : ' --no-verify --signoff'
44-
45- # Optional glob pattern of files which should be added to the commit
46- # Defaults to all (.)
47- # See the `pathspec`-documentation for git
48- # - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203
49- # - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
50- file_pattern : add-on/_locales
51-
52- # Optional. Local file path to the repository.
53- # Defaults to the root of the repository.
54- repository : .
55-
56- # Optional. Options used by `git-add`.
57- # See https://git-scm.com/docs/git-add#_options
58- add_options : ' -A'
59-
60- # Optional. Options used by `git-push`.
61- # See https://git-scm.com/docs/git-push#_options
62- push_options : ' --force-with-lease'
63-
64- # Optional. Disable dirty check and always try to create a commit and push
65- skip_dirty_check : true
66-
67- # Optional. Skip internal call to `git fetch`
68- skip_fetch : true
69-
70- # Optional. Skip internal call to `git checkout`
71- skip_checkout : true
72-
73- # Optional. Prevents the shell from expanding filenames.
74- # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
75- disable_globbing : true
76-
77- # Optional. Create given branch name in local and remote repository.
78- create_branch : true
40+ - name : Commit and push changes
41+ id : commit
42+ run : |
43+ # Configure git
44+ git config user.name "github-actions[bot]"
45+ git config user.email "github-actions[bot]@users.noreply.github.com"
46+
47+ # Add translation files
48+ git add -A add-on/_locales
49+
50+ # Check if there are changes to commit
51+ if git diff --staged --quiet; then
52+ echo "::notice::No translation changes detected from Transifex"
53+ {
54+ echo "## 📋 Transifex Sync Summary"
55+ echo ""
56+ echo "✅ **No changes detected**"
57+ echo ""
58+ echo "All translations are up to date."
59+ } >> "$GITHUB_STEP_SUMMARY"
60+ echo "changes=false" >> "$GITHUB_OUTPUT"
61+ else
62+ # Get statistics before committing
63+ STATS=$(git diff --staged --stat)
64+ FILES_CHANGED=$(git diff --staged --name-only)
65+ FILES_COUNT=$(echo "$FILES_CHANGED" | wc -l)
66+
67+ # Commit changes
68+ git commit --no-verify --signoff -m "chore: pull transifex translations"
69+ COMMIT_SHA=$(git rev-parse HEAD)
70+
71+ # Push to remote (force to handle any conflicts)
72+ git push origin i18n-sync --force
73+
74+ # Create GitHub annotations
75+ echo "::notice::Translation updates committed - $FILES_COUNT file(s) changed"
76+
77+ # Create job summary
78+ {
79+ echo "## 📋 Transifex Sync Summary"
80+ echo ""
81+ echo "✅ **Translation updates found and committed**"
82+ echo ""
83+ echo "**Commit:** \`$COMMIT_SHA\`"
84+ echo "**Files changed:** $FILES_COUNT"
85+ echo ""
86+ echo "### 📁 Changed files:"
87+ echo "\`\`\`"
88+ echo "$FILES_CHANGED"
89+ echo "\`\`\`"
90+ echo ""
91+ echo "### 📊 Statistics:"
92+ echo "\`\`\`diff"
93+ echo "$STATS"
94+ echo "\`\`\`"
95+ } >> "$GITHUB_STEP_SUMMARY"
96+
97+ {
98+ echo "changes=true"
99+ echo "commit_sha=$COMMIT_SHA"
100+ echo "files_count=$FILES_COUNT"
101+ } >> "$GITHUB_OUTPUT"
102+ fi
79103 - name : Create pull request
104+ if : steps.commit.outputs.changes == 'true'
80105 env :
81106 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82107 run : |
83108 # Check if PR already exists
84- existing_pr=$(gh pr list --base main --head i18n-sync --state open --json number --jq '.[0].number ' || true)
109+ existing_pr=$(gh pr list --base main --head i18n-sync --state open --json number,url --jq '.[0]' || true)
85110 if [ -n "$existing_pr" ]; then
86- echo "PR #$existing_pr already exists for i18n-sync -> main"
111+ PR_NUMBER=$(echo "$existing_pr" | jq -r '.number')
112+ PR_URL=$(echo "$existing_pr" | jq -r '.url')
113+ echo "::warning::Pull request #$PR_NUMBER already exists for i18n-sync branch"
114+
115+ # Update job summary with PR info
116+ {
117+ echo ""
118+ echo "### 🔗 Pull Request"
119+ echo "⚠️ **Existing PR updated:** [#$PR_NUMBER]($PR_URL)"
120+ } >> "$GITHUB_STEP_SUMMARY"
87121 else
88122 # Create new PR
89123 body="Automated translation update from Transifex.
90124
91- - Only pulls translated strings (empty strings fallback to English)
92- - Includes locales with 40%+ completion
125+ **Commit:** \\\`${{ steps.commit.outputs.commit_sha }}\\\`
126+ **Files changed:** ${{ steps.commit.outputs.files_count }}
127+
128+ - Only pulls translated strings (empty strings fallback to English)
129+ - Includes locales with 40%+ completion
93130
94- To contribute translations: https://explore.transifex.com/ipfs/ipfs-companion/"
131+ To contribute translations: https://explore.transifex.com/ipfs/ipfs-companion/"
95132
96- gh pr create \
133+ PR_URL=$( gh pr create \
97134 --base main \
98135 --head i18n-sync \
99136 --title "chore: pull new translations" \
100137 --body "$body" \
101- --label "need/triage" || echo "No changes to create PR"
138+ --label "need/triage" || echo "")
139+
140+ if [ -n "$PR_URL" ]; then
141+ echo "::notice::Pull request created: $PR_URL"
142+
143+ # Update job summary with PR info
144+ {
145+ echo ""
146+ echo "### 🔗 Pull Request"
147+ echo "✅ **New PR created:** $PR_URL"
148+ } >> "$GITHUB_STEP_SUMMARY"
149+ else
150+ echo "::error::Failed to create pull request"
151+ fi
102152 fi
0 commit comments