Merge pull request #260 from ungdev/dev #1224
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [master, dev] | |
pull_request: | |
branches: [master, dev] | |
jobs: | |
lint: | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
node-version: [18] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm pnpx prisma generate | |
- run: pnpm lint | |
build: | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
node-version: [18] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm pnpx prisma generate | |
- run: pnpm build | |
test: | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
node-version: [18] | |
env: | |
# Used for prisma generation | |
DATABASE_URL: mysql://test:test@localhost:3306/arena | |
services: | |
mariadb: | |
image: mariadb:10 | |
env: | |
MYSQL_USER: test | |
MYSQL_PASSWORD: test | |
MYSQL_DATABASE: arena | |
MYSQL_RANDOM_ROOT_PASSWORD: yes | |
ports: | |
- 3306:3306 | |
options: --name mariadb --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=30s --health-retries=5 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm pnpx prisma generate | |
- run: pnpm pnpx prisma db push | |
- run: docker exec -i mariadb mysql -utest -ptest arena < seed.sql | |
- run: pnpm test:coverage | |
- uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
deploy-dbdocs: | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
needs: | |
- lint | |
- build | |
- test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm pnpx prisma generate | |
- env: | |
BRANCH: ${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }} | |
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }} | |
run: pnpm dbdocs build dbml/schema.dbml --project=${{ env.BRANCH }} | |
deploy: | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
runs-on: self-hosted | |
needs: | |
- lint | |
- build | |
- test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install docker | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.REGISTRY_URL }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: | | |
${{ secrets.REGISTRY_URL }}/uttarena/api:${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }} |