fix: ingredients mess on recipe editing #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main Foodgram workflow | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| lint_backend_with_flake8: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.9 | |
| - name: Install flake8 | |
| run: pip install flake8==7.1.1 flake8-isort==6.1.2 | |
| - name: Run flake8 in backend directory | |
| run: cd backend/foodgram && python -m flake8 | |
| build_backend_and_push_it_to_docker_hub: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint_backend_with_flake8 | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/amd64 | |
| - 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 }}/foodgram_backend:latest | |
| build_frontend_and_push_it_to_docker_hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/amd64 | |
| - 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: ./frontend/ | |
| push: true | |
| tags: ${{ secrets.DOCKER_USERNAME }}/foodgram_frontend:latest | |
| build_gateway_and_push_it_to_docker_hub: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| platforms: linux/amd64 | |
| - 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: ./gateway/ | |
| push: true | |
| tags: ${{ secrets.DOCKER_USERNAME }}/foodgram_gateway:latest | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build_backend_and_push_it_to_docker_hub | |
| - build_frontend_and_push_it_to_docker_hub | |
| - build_gateway_and_push_it_to_docker_hub | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Copy docker-compose.prod.yaml via ssh | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USER }} | |
| key: ${{ secrets.SSH_KEY }} | |
| source: docker-compose.prod.yaml | |
| target: foodgram | |
| - 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 foodgram | |
| sudo docker compose -f docker-compose.prod.yaml down | |
| sudo docker compose -f docker-compose.prod.yaml pull | |
| sudo docker compose -f docker-compose.prod.yaml up -d | |
| sudo docker system prune -af | |
| send_telegram_message: | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| steps: | |
| - name: Send message | |
| uses: appleboy/telegram-action@master | |
| with: | |
| to: ${{ secrets.TELEGRAM_TO }} | |
| token: ${{ secrets.TELEGRAM_TOKEN }} | |
| message: Деплой Foodgram успешно выполнен! |