name: Check Internationalization

env:
  # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
  GO_VERSION: "1.17"

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
  push:
    branches:
      # Release branches have names like 0.8.x, 0.9.x, ...
      - "[0-9]+.[0-9]+.x"
  workflow_dispatch:
  repository_dispatch:

jobs:
  check:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Install Go
        uses: actions/setup-go@v3
        with:
          go-version: ${{ env.GO_VERSION }}

      - name: Install Task
        uses: arduino/setup-task@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          version: 3.x

      - name: Check i18n source and translation files are up to date
        run: task i18n:check
        env:
          TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
          TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
          TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
          TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
