cobranzas_dev ci.yml #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ms-cobranzas-dev-app || true | |
sudo mkdir -p /opt/ms-cobranzas-dev-app | |
- name: Clone GitHub repo | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ env.EC2_HOST }} | |
username: ${{ env.EC2_USERNAME }} | |
key: ${{ env.EC2_SSH_KEY }} | |
script: | | |
cd /opt/ms-cobranzas-dev-app | |
sudo git clone -b maicol_cobranzas https://${{ secrets.TOKEN_COBRANZAS }}@github.com/alkemyTech/UMSA-DevOps-T3 . | |
- 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/ms-cobranzas-dev-app | |
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/ms-cobranzas-dev-app | |
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 |