-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (62 loc) · 2.21 KB
/
foodgram_workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Foodgram workflow
on:
push:
branches:
- master
jobs:
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
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/#-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push backend
uses: docker/build-push-action@v2
with:
context: ./backend
push: true
tags: evol93/foodgram_backend:latest
- name: Push frontend
uses: docker/build-push-action@v2
with:
context: ./frontend
push: true
tags: evol93/foodgram_frontend:latest
deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
if: github.ref == 'refs/heads/master'
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: |
sudo rm .env
sudo touch .env
sudo chmod 666 .env
sudo echo DB_ENGINE=${{ secrets.DB_ENGINE }} >> .env
sudo echo DB_NAME=${{ secrets.DB_NAME }} >> .env
sudo echo POSTGRES_USER=${{ secrets.POSTGRES_USER }} >> .env
sudo echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env
sudo echo DB_HOST=${{ secrets.DB_HOST }} >> .env
sudo echo DB_PORT=${{ secrets.DB_PORT }} >> .env
sudo echo DEBUG=${{ secrets.DEBUG }} >> .env
sudo echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
sudo echo ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }} >> .env
cd infra/
sudo docker pull evol93/foodgram_backend:latest
sudo docker pull evol93/foodgram_frontend:latest
sudo docker-compose stop
sudo docker-compose rm backend
sudo docker-compose up -d --build