|
| 1 | +--- |
| 2 | +# Fetches translation/approval progress for every Crowdin project and: |
| 3 | +# 1. Upserts a single pinned GitHub issue whose body contains a Markdown |
| 4 | +# table per project with per-language translation and approval percentages, |
| 5 | +# sorted by lowest approval percentage first. |
| 6 | +# 2. Generates per-project SVG progress graphs and commits them to the |
| 7 | +# dedicated `crowdin-progress` branch so they can be embedded in READMEs |
| 8 | +# or other documents via jsDelivr or raw GitHub URLs. |
| 9 | +# |
| 10 | +# Required GitHub repository configuration: |
| 11 | +# secrets.CROWDIN_TOKEN – Crowdin personal access token |
| 12 | +# secrets.GH_BOT_TOKEN – GitHub PAT with "issues: write" and |
| 13 | +# "contents: write" permissions |
| 14 | +# vars.CROWDIN_PROJECT_IDS – Comma-separated list of Crowdin project IDs |
| 15 | +# (e.g. "123456" or "123456,789012") |
| 16 | +# vars.GH_BOT_NAME – Git commit author name |
| 17 | +# secrets.GH_BOT_EMAIL – Git commit author email |
| 18 | + |
| 19 | +name: Sync Crowdin Progress |
| 20 | +permissions: {} |
| 21 | + |
| 22 | +on: |
| 23 | + schedule: |
| 24 | + # Run once a day so progress stays reasonably fresh. |
| 25 | + - cron: '0 2 * * *' |
| 26 | + workflow_dispatch: # Allow ad-hoc manual runs |
| 27 | + |
| 28 | +# Only one sync at a time; never cancel an in-progress run. |
| 29 | +concurrency: |
| 30 | + group: crowdin-progress-sync |
| 31 | + cancel-in-progress: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + sync: |
| 35 | + name: Sync Crowdin progress to pinned issue and SVG branch |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: write |
| 39 | + issues: write |
| 40 | + if: github.repository_owner == 'LizardByte' # don't run for forks |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 45 | + with: |
| 46 | + token: ${{ secrets.GH_BOT_TOKEN }} |
| 47 | + |
| 48 | + - name: Set up Node.js |
| 49 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
| 50 | + with: |
| 51 | + node-version: 'node' |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: npm install --ignore-scripts |
| 55 | + |
| 56 | + - name: Sync Crowdin progress |
| 57 | + env: |
| 58 | + CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }} |
| 59 | + CROWDIN_PROJECT_IDS: ${{ vars.CROWDIN_PROJECT_IDS }} |
| 60 | + GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} |
| 61 | + GITHUB_REPOSITORY: ${{ github.repository }} |
| 62 | + SVG_OUTPUT_DIR: /tmp/crowdin-progress |
| 63 | + run: node src/crowdin-progress.js |
| 64 | + |
| 65 | + - name: Commit SVG graphs to crowdin-progress branch |
| 66 | + env: |
| 67 | + GH_BOT_NAME: ${{ vars.GH_BOT_NAME }} |
| 68 | + GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }} |
| 69 | + run: | |
| 70 | + git config user.name "${GH_BOT_NAME}" |
| 71 | + git config user.email "${GH_BOT_EMAIL}" |
| 72 | +
|
| 73 | + # Create an orphan branch so it contains only SVG files with no |
| 74 | + # history from main (keeps the branch lean). |
| 75 | + git checkout --orphan crowdin-progress |
| 76 | +
|
| 77 | + # Remove every file inherited from the main checkout. |
| 78 | + git rm -rf . --quiet |
| 79 | +
|
| 80 | + # Clean up any remaining untracked files / directories. |
| 81 | + git clean -fdx |
| 82 | +
|
| 83 | + # Populate the branch with the freshly generated SVG files. |
| 84 | + cp -r /tmp/crowdin-progress/. . |
| 85 | +
|
| 86 | + git add . |
| 87 | +
|
| 88 | + # Only commit when there are actual changes. |
| 89 | + if git diff --staged --quiet; then |
| 90 | + echo "No changes – SVG files are already up to date." |
| 91 | + else |
| 92 | + git commit -m "chore: update Crowdin progress SVGs" |
| 93 | + git push origin crowdin-progress --force |
| 94 | + fi |
0 commit comments