-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (56 loc) · 2.08 KB
/
deploy.yml
File metadata and controls
63 lines (56 loc) · 2.08 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
name: Build and Deploy API
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
Jwt__Issuer: "auth_service"
Jwt__Audience: "micro_services"
Logging__LogLevel__Default: "Information"
Logging__LogLevel__Microsoft.AspNetCore: "Warning"
Jwt__Key: ${{ secrets.JWT__KEY }}
ConnectionStrings__DevLocal: ${{ secrets.CONNECTIONSTRINGS__DEVLOCAL }}
steps:
- name: Checkout código
uses: actions/checkout@v3
- name: Generar llaves RSA
run: |
mkdir -p Keys
openssl genpkey -algorithm RSA -out Keys/private.key -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in Keys/private.key -out Keys/public.key
chmod 644 Keys/private.key
chmod 644 Keys/public.key
ls -la Keys/
- name: Configurar SSH
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Agregar host a known_hosts
run: ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
- name: Preparar y copiar archivos
run: |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} '
mkdir -p /var/www/toros-api.salazarcode.net &&
chmod -R 755 /var/www/toros-api.salazarcode.net
'
rsync -avz --delete ./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/var/www/toros-api.salazarcode.net/
- name: Build y Deploy Docker
run: |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} '
cd /var/www/toros-api.salazarcode.net &&
docker build -t toros-api . &&
docker stop toros-api || true &&
docker rm toros-api || true &&
docker run -d \
--name toros-api \
--network eventmanager_network \
-p 5000:80 \
-e ASPNETCORE_ENVIRONMENT=Production \
-e ASPNETCORE_URLS="http://+:80" \
-e USER=app \
--restart always \
toros-api
'