Files
chess-endgame-trainer/.github/workflows/ci.yml
T
2026-11-10 09:15:06 +01:00

97 lines
2.7 KiB
YAML

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.6
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@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
- uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b #v5.2.7
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
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@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
- uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b #v5.2.7
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
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