name: i18n-nightly-push

env:
  # See vars.GO_VERSION field of https://github.com/arduino/arduino-cli/blob/master/DistTasks.yml
  GO_VERSION: "1.19"

on:
  schedule:
    # run every day at 1AM
    - cron: '0 1 * * *'

jobs:
  push-to-transifex:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Node.js 16.x
        uses: actions/setup-node@v3
        with:
          node-version: '16.x'
          registry-url: 'https://registry.npmjs.org'

      - 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: Install dependencies
        run: yarn

      - name: Run i18n:push script
        run: yarn run i18n:push
        env:
          TRANSIFEX_ORGANIZATION: ${{ secrets.TRANSIFEX_ORGANIZATION }}
          TRANSIFEX_PROJECT: ${{ secrets.TRANSIFEX_PROJECT }}
          TRANSIFEX_RESOURCE: ${{ secrets.TRANSIFEX_RESOURCE }}
          TRANSIFEX_API_KEY: ${{ secrets.TRANSIFEX_API_KEY }}
