CLI: CI/CD integration

Last updated: October 09, 2023Author: Jakub Pomykała

Continuous integration and continuous deployment (CI/CD) is a practice that enables you to release new versions of your product quickly and frequently. You can include the SimpleLocalize CLI into your CI/CD pipeline to automate the process of uploading and downloading translations.

Workflow automation

SimpleLocalize can be integrated with any CI/CD service, simply put bash script somewhere in your scripting environment to find and push translation keys:

$ curl -s https://get.simplelocalize.io/2.5/install | bash
$ simplelocalize [command] --apiKey YOUR_API_KEY

The best place to run SimpleLocalize script is after a successful build because this will not result with wrong internationalization keys caused by invalid syntax. In case of any problems, please check the troubleshooting section or contact us at [email protected].

GitHub Actions

GitHub Actions Marketplace

SimpleLocalize GitHub Action is the easiest way to integrate SimpleLocalize with your GitHub repository. It's a ready-to-use GitHub Action that can be configured in a few minutes. The only thing you need to do is to create a new workflow file in your repository. Once you configure webhooks to trigger GitHub Actions from SimpleLocalize.

Sample .github/workflows/deploy.js workflow file:

name: 'My project'
on:
  push:
    branches: [ main ]

env:
  cli-version: '2.5.1'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Upload translations
        uses: simplelocalize/github-action-cli@v2
        with:
          api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
          command: 'upload'
          cli-version: ${{ env.cli-version }}
          args: '--uploadPath ./translations/{lang}.json --uploadFormat single-language-json'

      - name: Auto-translate project
        uses: simplelocalize/github-action-cli@v2
        with:
          api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
          command: 'auto-translate'
          cli-version: ${{ env.cli-version }}

      - name: Download translations
        uses: simplelocalize/github-action-cli@v2
        with:
          api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
          command: 'download'
          cli-version: ${{ env.cli-version }}
          args: '--downloadPath ./translations/{lang}.json --downloadFormat single-language-json'

      - name: Publish translations
        uses: simplelocalize/github-action-cli@v2
        with:
          api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
          command: 'publish'
          cli-version: ${{ env.cli-version }}
          args: '--environment _latest'

      - name: Pull translations
        uses: simplelocalize/github-action-cli@v2
        with:
          api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
          command: 'pull'
          cli-version: ${{ env.cli-version }}
          args: "--pullPath ./translation-hosting-resources/ --environment _latest --filterRegex '_index.json'"

Custom GitHub Action

The other way is to use the SimpleLocalize CLI directly.

Sample .github/workflows/deploy.js workflow file:

name: Deploy

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: SimpleLocalize
        run: curl -s https://get.simplelocalize.io/2.5/install | bash && simplelocalize [command]

AWS CodeBuild

Sample buildspec.yml

version: 0.1
phases:
  pre_build:
    commands:
      - yarn install
  build:
    commands:
      - yarn run test
      - yarn run build
      # Run SimpleLocalize
      - curl -s https://get.simplelocalize.io/2.5/install | bash && simplelocalize [command]