Skip to content

cobranzas_dev ci.yml #8

cobranzas_dev ci.yml

cobranzas_dev ci.yml #8

name: CI Cobranzas DEV
on:
push:
branches:
- maicol_cobranzas
jobs:
deploy:
runs-on: ubuntu-latest
env:
EC2_HOST: ${{ secrets.IP_COBRANZAS_DEV }}
EC2_USERNAME: ${{ secrets.USERS_COBRANZAS }}
EC2_SSH_KEY: ${{ secrets.PEM_ORG_COBRANZAS_DEV }}
GH_TOKEN: ${{ secrets.TOKEN_COBRANZAS }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Install dependencies
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
sudo yum install -y nodejs npm git
- name: Create working directory
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
sudo rm -rf /opt/nombreDeSuDirectorio || true
sudo mkdir -p /opt/nombreDeSuDirectorio
- name: Clone GitHub repo
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
sudo git clone https://${{ env.GH_TOKEN }}@github.com/usuario/repo /opt/nombreDeSuDirectorio
- name: Install npm packages
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
cd /opt/nombreDeSuDirectorio
sudo npm install express pm2
- name: Start service
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
cd /opt/nombreDeSuDirectorio
sudo pm2 start app.js
- name: Check service status
uses: appleboy/ssh-action@master
with:
host: ${{ env.EC2_HOST }}
username: ${{ env.EC2_USERNAME }}
key: ${{ env.EC2_SSH_KEY }}
script: |
sudo pm2 status