Skip to content

Update ci_pagos_qa.yml #27

Update ci_pagos_qa.yml

Update ci_pagos_qa.yml #27

Workflow file for this run

name: CI Pagos qa
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_ORG_PAGOS_DEV }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ secrets.IP_PAGOS_QA }}
APP_NAME: app.js
on:
push:
branches:
- franco-pagos-qa
jobs:
ci-pagos-qa:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Crear directorio de trabajo en la máquina EC2
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
sudo rm -rf /opt/ms-pagos-qa-app || true
sudo mkdir -p /opt/ms-pagos-qa-app
sudo usermod -aG docker $USER
- name: Clonar repositorio de GitHub
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/ms-pagos-qa-app
sudo git clone -b franco-pagos-qa https://${{ secrets.TOKEN_PAGOS }}@github.com/alkemyTech/UMSA-DevOps-T3 .
# Instalar Docker
- name: Install Docker
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
if ! command -v docker &> /dev/null
then
echo "Docker is not installed. Installing Docker..."
sudo yum update -y
sudo yum install -y docker
else
echo "Docker is already installed."
fi
if ! systemctl is-active --quiet docker
then
echo "Docker is not running. Starting Docker..."
sudo systemctl start docker
else
echo "Docker is already running."
fi
# Construir la imagen Docker
- name: Build Docker image
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
script: |
cd /opt/ms-pagos-qa-app
docker rmi pagosimagen || true
docker build -t pagosimagen .
# Autenticación en DockerHub
- name: Login to DockerHub
run: echo "${{ secrets.DOCKERPAGO_TOKEN }}" | docker login -u "${{ secrets.dockerUserpago }}" --password-stdin
# Subir imagen a DockerHub
#- name: Push image to DockerHub
# run: docker push "${{secrets.dockerUserpago}}"/pagosimagen:latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.dockerUserpago }}/pagosimagen:latest
username: ${{ secrets.dockerUserpago }}
password: ${{ secrets.DOCKERPAGO_TOKEN }}
# Despliegue al entorno de QA (manual)
- name: Desplegar al entorno de QA
if: always()
run: echo "Presiona un botón para desplegar en QA"