Skip to content

compras_qa_manual_v2 #20

compras_qa_manual_v2

compras_qa_manual_v2 #20

name: compras_qa_manual_v2
# Configure Manual Trigger
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
#Conexion ssh
SSH_PRIVATE_KEY: ${{ secrets.PEM_FILE_COMPRAS }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ vars.AWS_DEV_HOST_COMPRAS_QA }}
#Conexion dockerhub
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME_COMPRAS_QA }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD_COMPRAS_QA }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN_COMPRAS_QA }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Generar Imagen Docker
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: false
tags: ${{ env.DOCKERHUB_USERNAME }}/compras_qa:latest
- name: Iniciar sesion en docker hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_PASSWORD }}
- name: Subir a DockerHub
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/compras_qa:latest
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Actualizar el sistema e instalar Docker
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo yum update -y
sudo yum install docker -y
sudo service docker start
sudo usermod -aG docker ec2-user
- name: Eliminar contenedor
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
docker stop compras_qa_il || true
docker rm compras_qa_il || true
- name: Ejecutar contenedor en EC2
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
docker run -d -p 3000:3000 --name compras_qa_il ${{ env.DOCKERHUB_USERNAME }}/compras_qa:latest
- name: MOstrar informacion de la pagina
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo curl localhost:3000