Skip to content

Setup Git flow

Setup Git flow #14

Workflow file for this run

name: CI/CD Backend
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
- feature/*
- release/*
- hotfix/*
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.19.1"
- name: Install dependencies
run: |
cd backend
npm install
- name: Set executable permissions
run: |
cd backend
chmod +x node_modules/.bin/eslint node_modules/.bin/jest
- name: Run lint
run: |
cd backend
npm run lint
- name: Run tests
env:
DATABASE_HOST: 127.0.0.1
DATABASE_PORT: 5432
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_NAME: test_db
run: |
cd backend
npm test
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/backend:latest -f backend/Dockerfile ./backend
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/backend:latest
- name: Deploy to Railway
if: github.ref == 'refs/heads/main'
env:
_API_KEY: ${{ secrets.RENDER_API_KEY }}
run: |
curl -X POST -H "Accept: application/json" -H "Authorization: Bearer ${{ secrets.RENDER_API_KEY }}" -d '' https://api.render.com/deploy/srv-xxxxxxxxxxxxxxxxxx