Skip to content

Commit

Permalink
Create main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
luydmila-davletova committed Nov 28, 2023
1 parent b327a4c commit 6f2b117
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Django-app workflow

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11

- name: Install dependencies
run: |
# обновление pip
python -m pip install --upgrade pip
pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort
pip install -r requirements.txt
- name: Test with flake8 and django tests
run: |
python -m flake8
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: certelen/azu_cafe_django

deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
steps:
- name: executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
# Выполняет pull образа с DockerHub
sudo docker pull certelen/azu_cafe_django
#остановка всех контейнеров
sudo docker stop $(sudo docker ps -a -q)
sudo docker run --rm -d -p 5000:5000 certelen/azu_cafe_django

0 comments on commit 6f2b117

Please sign in to comment.