name: CI for back (strapi) service

on:
  push:
    paths:
      - "back/**"

jobs:
  test-back:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    defaults:
      run:
        working-directory: ./back

    env:
      HOST: 0.0.0.0
      PORT: 1337
      APP_KEYS: "TestPurposeOnly1,TestPurposeOnly2"
      API_TOKEN_SALT: TestPurposeOnly
      ADMIN_JWT_SECRET: TestPurposeOnly
      JWT_SECRET: TestPurposeOnly

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

      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
          cache: 'yarn'
          cache-dependency-path: "**/yarn.lock"

      - name: Install dependencies
        run: yarn install

      - name: Run linter
        run: yarn run lint

      - name: Run tests
        run: yarn run test