Skip to content

monorepo ci workflow added #3

monorepo ci workflow added

monorepo ci workflow added #3

Workflow file for this run

name: Build CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
DJANGO_SETTINGS_MODULE: djangoindia.settings.production
SECRET_KEY: test-key-not-for-production
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install Django dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/production.txt
- name: Run Django migrations
run: python manage.py migrate
- name: Run Django system checks
run: python manage.py check
# - name: Run Django tests
# run: python manage.py test
# # Commented out as there are no tests currently
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend
env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
NEXT_PUBLIC_FRONTEND_URL: ${{ secrets.NEXT_PUBLIC_FRONTEND_URL }}
NODE_ENV: production
NEXT_TELEMETRY_DISABLED: 1
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './frontend/package-lock.json'
- name: Install Next.js dependencies
run: npm ci
- name: Install development dependencies
run: npm install --save-dev tailwindcss postcss autoprefixer sharp
- name: Setup PostCSS
run: |
echo "module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}" > postcss.config.js
- name: Setup Tailwind CSS
run: |
echo "module.exports = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
}" > tailwind.config.js
- name: Build Next.js app
run: npm run build
env:
NEXT_TELEMETRY_DISABLED: 1
NODE_ENV: production
# - name: Run Next.js tests
# run: npm test
# # Commented out as there are no tests currently
- name: Verify build output
run: |
if [ ! -d ".next" ]; then
echo "Build failed - .next directory not found"
exit 1
fi