-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.86 KB
/
CI_Pipeline-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
name: CI Pipeline - DEV
on:
push:
branches:
- martin-proveedores
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_PROV_DEV }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ secrets.IP_PROV_DEV }}
GH_TOKEN: ${{ secrets.TOKEN_PROV }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Install Node.js, NPM, and Git
run: |
sudo apt-get update
sudo apt-get install nodejs npm git -y
- name: Clone Repo
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
# Check if Git is installed, if not, install it
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed. Installing git...' >&2
sudo yum update -y
sudo yum install git -y
fi
cd /opt
sudo rm -rf /opt/appDir # Remove directory if exists
sudo git clone https://${{ secrets.GH_TOKEN }}@github.com/alkemyTech/UMSA-DevOps-T3 /opt/appDir
- name: Install NPM Packages
run: |
sudo mkdir -p /opt/appDir # Create directory if it doesn't exist
cd /opt/appDir # Change directory to /opt/appDir
npm init -y # Initialize package.json with default values
sudo npm install -g express pm2
npm install
- name: Start Node Service
run: |
sleep 5 # Espera 5 segundos
sudo $(which pm2) start -f app.js
- name: Check if Application is Running
run: |
sudo pm2 status