-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (73 loc) · 2.66 KB
/
ci_dev.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
name: CI ambiente DEV
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_FILE }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ vars.AWS_DEV_HOST }}
APP_NAME: app.js
on:
push:
branches:
- gonzalo-compras
jobs:
ci_dev:
name: CI ambiente DEV
runs-on: ubuntu-latest
steps:
- name: Instalar paquetes
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo yum install -y nodejs npm git
- name: Crear directorio
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo rm -rf /opt/compras || true
sudo mkdir -p /opt/compras
- name: Crear clonar repositorio
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/compras
sudo git clone -b gonzalo-compras https://${{ secrets.GIT_PAT }}@github.com/alkemyTech/UMSA-DevOps-T3
- name: Instalar paquetes
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/compras
sudo npm i -g express pm2
- name: Iniciar servicio
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/compras
sudo pm2 start app.js
- name: Test app
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/compras
if curl http://localhost:3000 > /dev/null; then
echo "App ok"
else
echo "Error"
exit 1
fi