[init] project
This commit is contained in:
Executable
+63
@@ -0,0 +1,63 @@
|
||||
name: Django CI/CD
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
migrations:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
DJANGO_DEBUG: True
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install production dependencies
|
||||
run: pip install -r backend/requirements/prod.txt
|
||||
- name: Check for pending migrations
|
||||
run: cd backend/project && python manage.py makemigrations --check --dry-run
|
||||
|
||||
linting:
|
||||
runs-on: ubuntu-latest
|
||||
needs: migrations
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install linting dependencies
|
||||
run: pip install -r backend/requirements/dev.txt
|
||||
- name: Lint with ruff
|
||||
run: cd backend && ruff check .
|
||||
|
||||
testing:
|
||||
runs-on: self-hosted
|
||||
needs: linting
|
||||
|
||||
env:
|
||||
DJANGO_DEBUG: True
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install test dependencies
|
||||
run: pip install -r backend/requirements/test.txt
|
||||
- name:
|
||||
run: cd backend/project && python manage.py test
|
||||
|
||||
test_build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: testing
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build Docker image
|
||||
run: docker build -t skillhub_backend backend/
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Deployment
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Frontend CI/CD"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ github.ref == 'refs/heads/main' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Pull Docker images and start containers
|
||||
run: |
|
||||
sudo docker compose up -d --build
|
||||
@@ -0,0 +1,32 @@
|
||||
name: Frontend CI/CD
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Django CI/CD"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
linting:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '18'
|
||||
- name: Install dependencies
|
||||
run: cd frontend && npm install
|
||||
- name: Linting
|
||||
run: cd frontend && npm run lint
|
||||
continue-on-error: true
|
||||
|
||||
test_build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: linting
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build Docker image
|
||||
run: docker build -t skillhub-backend frontend/
|
||||
Reference in New Issue
Block a user