---
kind: pipeline
type: kubernetes
name: test-lint
concurrency:
  limit: 1
metadata:
  namespace: git
steps:
  - name: Test/Lint
    image: node:current-bullseye
    volumes:
      - name: cache
        path: /cache
    environment:
      YARN_CACHE_FOLDER: /cache/.yarn-test
    commands:
      - yarn install
      - yarn eslint src/
      - yarn prettier --check src/
      - yarn tsc --noEmit
volumes:
  - name: cache
    claim:
      name: docker-cache
---
kind: pipeline
type: kubernetes
name: crowdin
concurrency:
  limit: 1
trigger:
  branch:
    - main
metadata:
  namespace: git
steps:
  - name: Push/Pull translations
    image: node:current-bullseye
    volumes:
      - name: cache
        path: /cache
    environment:
      YARN_CACHE_FOLDER: /cache/.yarn-translations
      TOKEN:
        from_secret: gitea
      CTOKEN:
        from_secret: crowdin
    commands:
      - git config --global user.email drone@v0l.io
      - git config --global user.name "Drone CI"
      - git remote set-url origin https://drone:$TOKEN@git.v0l.io/Kieran/stream.git
      - yarn install
      - npx @crowdin/cli upload sources -b main -T $CTOKEN
      - npx @crowdin/cli pull -b main -T $CTOKEN
      - yarn prettier --write .
      - git add .
      - >
        if output=$(git status --porcelain) && [ -n "$output" ]; then
          git commit -a -m "chore: Update translations"
          git push -u origin main
        fi
volumes:
  - name: cache
    claim:
      name: docker-cache
