-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (92 loc) · 2.87 KB
/
production.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Production
on:
pull_request:
branches: [ "production" ]
jobs:
build-api:
name: Build backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./src/backend/EcoLink.WebApi/
- name: Build
run: dotnet build --configuration Release --output out --verbosity normal ./src/backend/EcoLink.WebApi/
dockerize-api:
name: Dockerize backend
needs: build-api
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PROJECT: ${{ secrets.PROJECT }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Login to DockerHub
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- name: Build and push
run: |
docker build --tag $DOCKER_USERNAME/$PROJECT-api --file ./src/backend/EcoLink.WebApi/Dockerfile .
docker push $DOCKER_USERNAME/$PROJECT-api
build-bot:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore ./src/frontend/EcoLink.Bot/
- name: Build
run: dotnet build --configuration Release --output out --verbosity normal ./src/frontend/EcoLink.Bot/
dockerize-bot:
name: Dockerize Bot
needs: build-bot
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PROJECT: ${{ secrets.PROJECT }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Login to DockerHub
run: |
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
- name: Build and push
run: |
docker build --tag $DOCKER_USERNAME/$PROJECT-bot --file ./src/frontend/EcoLink.Bot/Dockerfile .
docker push $DOCKER_USERNAME/$PROJECT-bot
deploy:
name: Deploy
needs:
- dockerize-api
- dockerize-bot
runs-on: ubuntu-latest
steps:
- name: SSH into AWS Ubuntu Server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
cd ~/eco-link
docker-compose pull
docker rmi $(docker images --quiet --filter dangling=true)
docker-compose up --detach