name: CI on: pull_request: push: branches: [main] permissions: contents: read concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: test: name: Test runs-on: ubuntu-24.04 env: MIX_ENV: test services: postgres: image: postgres:18.0 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - 5432:5432 options: >- --health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s --health-retries 10 steps: - uses: actions/checkout@v7 - uses: jdx/mise-action@v2 - uses: actions/cache@v4 with: path: | deps ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-mix-test-${{ hashFiles('mix.lock', 'mise.toml') }} restore-keys: | ${{ runner.os }}-mix-test- - run: mix local.hex --force - run: mix local.rebar --force - run: mix deps.get - run: mix format --check-formatted - run: mix precommit build-release: name: Build release needs: test runs-on: ubuntu-24.04 env: MIX_ENV: prod SECRET_KEY_BASE: build-only-secret-key-base-build-only-secret-key-base-build-only-secret-key-base DATABASE_URL: ecto://postgres:postgres@127.0.0.1:5432/chesstrainer_build SES_REGION: eu-north-1 SES_ACCESS_KEY_ID: build SES_SECRET_ACCESS_KEY: build steps: - uses: actions/checkout@v7 - uses: jdx/mise-action@v2 - uses: actions/cache@v4 with: path: | deps ~/.cargo/registry ~/.cargo/git assets/node_modules key: ${{ runner.os }}-mix-prod-${{ hashFiles('mix.lock', 'mise.toml', 'assets/package-lock.json') }} restore-keys: | ${{ runner.os }}-mix-prod- - run: mix local.hex --force - run: mix local.rebar --force - run: npm ci --prefix assets --no-audit --no-fund - run: mix deps.get --only prod - run: mix assets.setup - run: mix assets.deploy - run: mix release - run: tar -czf chesstrainer-release.tar.gz -C _build/prod/rel/chesstrainer . - uses: actions/upload-artifact@v4 with: name: chesstrainer-release path: chesstrainer-release.tar.gz retention-days: 7