-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gonzalo
committed
Apr 2, 2024
1 parent
23a6296
commit 694c6af
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |