Add Postgres #3226
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: [v2] | |
pull_request: | |
branches: [v2] | |
jobs: | |
nodejs: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: keepitsecret | |
POSTGRES_USER: testdb | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: textbook/take-action@nodejs | |
with: | |
node-version: 20 | |
- run: npx playwright install --with-deps | |
- run: npm run lint | |
- run: npm run test:cover | |
env: | |
DATABASE_URL: postgres://testdb:keepitsecret@localhost:5432/testdb | |
FORCE_COLOR: true | |
- run: npm run e2e | |
env: | |
DATABASE_URL: postgres://testdb:keepitsecret@localhost:5432/testdb | |
- run: npm run e2e:dev | |
env: | |
DATABASE_URL: postgres://testdb:keepitsecret@localhost:5432/testdb | |
docker: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: keepitsecret | |
POSTGRES_USER: testdb | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: textbook/take-action@nodejs | |
with: | |
node-version: 20 | |
- run: npx playwright install --with-deps | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/build-push-action@v5 | |
with: | |
load: true | |
push: false | |
tags: textbook/starter-kit:v2 | |
- id: env-file | |
run: | | |
echo "file=$ENV_FILE" >> $GITHUB_OUTPUTS | |
echo 'LOG_LEVEL=debug' >> $ENV_FILE | |
echo 'NODE_ENV=docker' >> $ENV_FILE | |
echo 'DATABASE_URL=postgres://testdb:keepitsecret@localhost:5432/testdb' >> $ENV_FILE | |
env: | |
ENV_FILE: docker.env | |
- id: docker-run | |
run: | | |
echo "id=$(docker run \ | |
--detach \ | |
--env-file ${{ steps.env-file.outputs.file }} \ | |
--init \ | |
--publish 4321:80 \ | |
textbook/starter-kit:v2)" >> $GITHUB_OUTPUT | |
- run: npm run e2e | |
env: | |
PLAYWRIGHT_BASE_URL: http://localhost:4321 | |
- if: always() && steps.docker-run.outputs.id | |
run: docker logs ${{ steps.docker-run.outputs.id }} |