Skip to content

postgresql

postgresql #84

Workflow file for this run

name: Test pep8
on:
push:
branches:
- main
pull_request:
jobs:
tests:
name: Test with flake8 and django tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_DB: postgres
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
ports:
- 5432:5432
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install flake8==6.0.0 flake8-isort==6.0.0
pip install -r requirements.txt
- name: Run linting
run: |
flake8 .
- name: Run Django tests
working-directory: ./backend
run: |
python manage.py test
build_and_push_to_docker_hub:
name: Push Docker image to DockerHub
needs: tests
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to DockerHub
uses: docker/build-push-action@v4
with:
context: ./backend/
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/backend:latest
deploy:
name: Deploy project
needs:
- tests
- build_and_push_to_docker_hub
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd hackaton_10
docker compose pull
docker compose down
docker compose up -d
docker image prune -f