-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (57 loc) · 2.03 KB
/
main.yml
File metadata and controls
64 lines (57 loc) · 2.03 KB
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
name: CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build .
--file Dockerfile
--tag ${{ secrets.DOCKER_HUB_USERNAME }}/communications_api:${{ github.sha }}
--tag ${{ secrets.DOCKER_HUB_USERNAME }}/communications_api:latest
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Push the Docker image to the repository
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/communications_api:latest
deploy:
runs-on: ubuntu-latest
needs: build-image
steps:
- uses: actions/checkout@v2
- name: Upload static and configs over SCP
uses: appleboy/scp-action@master
with:
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.ACTOR_PRIVATE_KEY }}
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
source: |
static/*,
docker-compose.yml,
nginx.conf,
scripts/*
target: /var/www/code/communications_api/
- name: Deploy over SSH
uses: appleboy/ssh-action@v0.1.10
with:
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.ACTOR_PRIVATE_KEY }}
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
# Тут стоит сделать переменной имя сервера, but not today
script: |
export MY_EMAIL=${{ secrets.MY_EMAIL }}
export APP_NAME=communications_api
cd /var/www/code/$APP_NAME
echo ${{ secrets.SUDO_PASSWORD }} | \
sudo -S chmod +x scripts/*.sh
echo ${{ secrets.SUDO_PASSWORD }} | \
sudo -S -E APP_NAME=$APP_NAME MY_EMAIL=$MY_EMAIL scripts/deploy.sh