Skip to content

prueba5

prueba5 #5

Workflow file for this run

name: Deploy App ventas
# Trigger on push
on:
push:
branches:
- ventas_qa_sc
jobs:
build:
runs-on: ubuntu-latest
# Variables de entorno
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME_SANTIAGO }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN_SANTIAGO }}
APP_NAME: app.js
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
# https://github.com/docker/build-push-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USER }}
password: ${{ env.DOCKER_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.DOCKER_USER }}/ventas_qa_sc:latest
deploy:
needs: build
runs-on: ubuntu-latest
# Variables de entorno
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_FILE_VENTAS_QA }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ vars.IP_EC2_VENTAS_QA }}
APP_NAME: app.js
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
# Install Docker in EC2, pull and run container
- name: Install 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 systemctl start docker
sudo systemctl enable docker
docker --version
sudo docker rm -f VENTAS_QA || true
sudo docker pull santicenturion/ventas_qa_sc:latest
sudo docker run -d --name VENTAS_QA -p 3000:3000 --restart always santicenturion/ventas_qa_sc:latest