Add ci #3
Workflow file for this run
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: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
env: | |
DATABASE_URL: "postgresql://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432/fact?schema=public" | |
URL_DEV: "http://127.0.0.1" | |
PORT: 3000 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Start PostgreSQL container | |
run: | | |
docker run -d --name postgres \ | |
-e POSTGRES_USER=${{ secrets.POSTGRES_USER }} \ | |
-e POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} \ | |
-p 5432:5432 \ | |
postgres:10.3 | |
# Wait for PostgreSQL to be ready | |
while ! docker exec postgres pg_isready -U ${{ secrets.POSTGRES_USER }}; do sleep 1; done | |
- name: Generate Prisma client | |
run: pnpm prisma generate | |
- name: Apply Prisma migrations | |
run: pnpm prisma migrate deploy | |
- name: Run tests | |
run: pnpm test | |
- name: Stop PostgreSQL container | |
run: docker stop postgres && docker rm postgres |