-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (68 loc) · 2.5 KB
/
ci_app_node.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: MS-CLIENTES-DEV CI
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_MS_CLIENTES_DEV }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ secrets.IP_CLIENTES_DEV }}
APP_NAME: app.js
on:
push:
branches: [ "romina-clientes" ]
jobs:
ci-clientes-dev:
runs-on: ubuntu-latest
steps:
- name: Checkout código fuente
uses: actions/checkout@v3
- name: Instalar paquetes nodejs npm git
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/ms-clientes-dev-app
sudo mkdir /opt/ms-clientes-dev-app
- name: Clonar repositorio
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo git clone -b romina-clientes https://${{ secrets.TOKEN_GH_CLIENTES }}@github.com/alkemyTech/UMSA-DevOps-T3 /opt/ms-clientes-dev-app
- name: Instalar paquetes con NPM
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo npm install express pm2 -g
- name: Iniciar aplicación Node con PM2
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/ms-clientes-dev-app
pm2 start app.js
- name: Verificar estado de la aplicación
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/ms-clientes-dev-app
pm2 status