[feat] Added properly CI/CD
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
name: Django CI/CD
|
name: Django CI
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
checking:
|
migrations:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
env:
|
||||||
|
DJANGO_DEBUG: False
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -12,15 +15,15 @@ jobs:
|
|||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
- name: Copy env file
|
|
||||||
run: cp backend/template.env backend/.env
|
|
||||||
- name: Install production dependencies
|
- name: Install production dependencies
|
||||||
run: pip install -r backend/requirements/prod.txt
|
run: pip install -r backend/requirements/prod.txt
|
||||||
- name: Check for pending migrations
|
- name: Check for pending migrations
|
||||||
run: cd backend/project && python manage.py makemigrations --check --dry-run
|
run: cd backend/project && python manage.py makemigrations --check --dry-run
|
||||||
|
|
||||||
linting:
|
linting:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
needs: migrations
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
@@ -33,20 +36,36 @@ jobs:
|
|||||||
run: cd backend && ruff check .
|
run: cd backend && ruff check .
|
||||||
|
|
||||||
testing:
|
testing:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
needs: linting
|
||||||
|
|
||||||
|
env:
|
||||||
|
DJANGO_DEBUG: False
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
- name: Copy env file
|
- name: Install test dependencies
|
||||||
run: cp backend/template.env backend/.env
|
run: pip install -r backend/requirements/test.txt
|
||||||
- name: Install prod dependencies
|
- name:
|
||||||
run: pip install -r backend/requirements/prod.txt
|
run: cd backend/project && python manage.py test
|
||||||
- name: Test production environment
|
|
||||||
run: cd backend/project && DJANGO_DEBUG=False python manage.py test
|
build_and_push:
|
||||||
- name: Install dev dependencies
|
runs-on: self-hosted
|
||||||
run: pip install -r backend/requirements/dev.txt
|
needs: testing
|
||||||
- name: Test development environment
|
|
||||||
run: cd backend/project && DJANGO_DEBUG=True python manage.py test
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: docker.io
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
- name: Build Docker image
|
||||||
|
run: docker build -t skillhub/backend backend/
|
||||||
|
- name: Push Docker image
|
||||||
|
run: docker push skillhub/backend
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: Deployment
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Django CI/CD", "Frontend CI/CD"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: self-hosted
|
||||||
|
if: github.event.workflow_run.conclusion == 'success'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: docker.io
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
- name: Pull Docker images and start containers
|
||||||
|
run: docker-compose up -d
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
name: Frontend CI/CD
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linting:
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Linting
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
build_and_push:
|
||||||
|
runs-on: self-hosted
|
||||||
|
needs: linting
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: docker.io
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
|
- name: Build and push Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t skillhub/frontend frontend/
|
||||||
|
docker push skillhub/frontend
|
||||||
Reference in New Issue
Block a user