Browse Source

feat: add crowdin github actions

pull/627/head
Dan Ditomaso 1 year ago
parent
commit
a421b134e9
  1. 3
      .github/workflows/ci.yml
  2. 35
      .github/workflows/crowdin-download.yml
  3. 28
      .github/workflows/crowdin-upload-sources.yml
  4. 25
      .github/workflows/crowdin-upload-translations.yml
  5. 22
      .github/workflows/update-stable-from-master.yml
  6. 10
      crowdin.yml

3
.github/workflows/ci.yml

@ -1,10 +1,9 @@
name: Push to Master/Main CI name: Push to Main CI
on: on:
push: push:
branches: branches:
- main - main
- master
permissions: permissions:
contents: write contents: write

35
.github/workflows/crowdin-download.yml

@ -0,0 +1,35 @@
name: Crowdin Download Translations Action
on:
schedule: # Every Sunday at midnight
- cron: '0 0 * * 0'
workflow_dispatch: # Allow manual triggering
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download translations with Crowdin
uses: crowdin/github-action@v2
with:
base_url: 'https://meshtastic.crowdin.com/api/v2'
config: 'crowdin.yml'
upload_sources: false
upload_translations: false
download_translations: true
localization_branch_name: i18n_crowdin_translations
commit_message: 'chore(i18n): New Crowdin Translations by GitHub Action'
create_pull_request: true
pull_request_title: 'chore(i18n): New Crowdin Translations'
pull_request_body: 'New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)'
pull_request_base_branch_name: 'main'
pull_request_labels: 'i18n'
crowdin_branch_name: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

28
.github/workflows/crowdin-upload-sources.yml

@ -0,0 +1,28 @@
name: Crowdin Upload Sources Action
on:
push: # Watch source en.json for changes on main
paths: [ '/src/i18n/locales/en.json' ]
branches: [ main ]
workflow_dispatch: # Allow manual triggering
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upload sources with Crowdin
uses: crowdin/github-action@v2
with:
base_url: 'https://meshtastic.crowdin.com/api/v2'
config: 'crowdin.yml'
upload_sources: true
upload_translations: false
download_translations: false
crowdin_branch_name: 'main'
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

25
.github/workflows/crowdin-upload-translations.yml

@ -0,0 +1,25 @@
name: Crowdin Upload Translations Action
on:
workflow_dispatch: # Allow manual triggering
jobs:
synchronize-with-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Upload translations with Crowdin
uses: crowdin/github-action@v2
with:
base_url: "https://meshtastic.crowdin.com/api/v2"
config: "crowdin.yml"
upload_sources: false
upload_translations: true
download_translations: false
crowdin_branch_name: "main"
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

22
.github/workflows/update-stable-from-master.yml

@ -1,4 +1,4 @@
name: Update Stable Branch from Master on Latest Release name: Update Stable Branch from Main on Latest Release
on: on:
release: release:
@ -9,7 +9,7 @@ permissions:
jobs: jobs:
update-stable-branch: update-stable-branch:
name: Update Stable Branch from Master name: Update Stable Branch fromMain
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -24,14 +24,14 @@ jobs:
git config user.name "GitHub Actions Bot" git config user.name "GitHub Actions Bot"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Fetch latest master and stable branches - name: Fetch latest main and stable branches
run: | run: |
git fetch origin master:master git fetch origin main:main
git fetch origin stable:stable || echo "Stable branch not found remotely, will create." git fetch origin stable:stable || echo "Stable branch not found remotely, will create."
- name: Get latest master commit SHA - name: Get latest main commit SHA
id: get_master_sha id: get_main_sha
run: echo "MASTER_SHA=$(git rev-parse master)" >> $GITHUB_ENV run: echo "MAIN_SHA=$(git rev-parse main)" >> $GITHUB_ENV
- name: Check out stable branch - name: Check out stable branch
run: | run: |
@ -39,12 +39,12 @@ jobs:
git checkout stable git checkout stable
git pull origin stable # Sync with remote stable if it exists git pull origin stable # Sync with remote stable if it exists
else else
echo "Creating local stable branch based on master HEAD." echo "Creating local stable branch based on main HEAD."
git checkout -b stable ${{ env.MASTER_SHA }} git checkout -b stable ${{ env.MAIN_SHA }}
fi fi
- name: Reset stable branch to latest master - name: Reset stable branch to latest main
run: git reset --hard ${{ env.MASTER_SHA }} run: git reset --hard ${{ env.MAIN_SHA }}
- name: Force push stable branch - name: Force push stable branch
run: git push origin stable --force run: git push origin stable --force

10
crowdin.yml

@ -0,0 +1,10 @@
"project_id_env": "CROWDIN_PROJECT_ID"
"api_token_env": "CROWDIN_PERSONAL_TOKEN"
"base_path": "."
"base_url": "https://meshtastic.crowdin.com/api/v2"
"preserve_hierarchy": true
files:
- source: /src/i18n/locales/en.json
translation: /src/i18n/locales/%two_letters_code%.json
Loading…
Cancel
Save