Skip to content

updated deployment #115

updated deployment

updated deployment #115

Workflow file for this run

name: CI/CD for Backend
on:
push:
branches: [main, master]
pull_request:
types: [opened, closed]
branches: [main, master]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Set Environment Variables
run: |
echo "MONGODB_USER=${{ secrets.MONGODB_USER }}" >> $GITHUB_ENV
echo "MONGO_PWD=${{ secrets.MONGO_PWD }}" >> $GITHUB_ENV
echo "DB_HOST=${{ secrets.DB_HOST }}" >> $GITHUB_ENV
echo "API_KEY=${{ secrets.API_KEY }}" >> $GITHUB_ENV
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend_api/requirements.txt
pip install pytest
pip install pylint black
- name: Run Pylint
run: pylint backend_api/ --ignore-patterns='.*\.pb2\.py,.*\.pb2_grpc\.py'
- name: Run Black (Check mode)
run: black backend_api/
- name: Run tests
run: pytest tests/web_app_tests.py
# Additional step to log into Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Building Docker image for backend api and push to Docker Hub
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/backend-api:latest
context: ./backend_api
file: ./backend_api/Dockerfile