fix: do not preconnect to database #1
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/CD | |
on: | |
push: | |
branches: | |
- main | |
env: | |
NODE_VERSION: 22 | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Format | |
run: npm run format | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Check | |
run: npm run check | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Test | |
run: npm run test | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- format | |
- check | |
- test | |
env: | |
# Just needs to be defined, doesn't need to be a real URL | |
DATABASE_URL: mongodb://mongo:27017/ementas | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
env: | |
# Just needs to be defined, doesn't need to be a real URL | |
DATABASE_URL: mongodb://mongo:27017/ementas | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Docker registry | |
uses: docker/login-action@v3 | |
with: | |
registry: https://registry.toino.pt | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Copy example .env | |
run: cp .env.example .env | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: registry.toino.pt/ementas:latest | |
target: prod |