Skip to content

Commit

Permalink
Create CD QA Proveedores.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaJuliaBalza authored Apr 17, 2024
1 parent b4904a3 commit ec2f96f
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/CD QA Proveedores.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Push Docker Image QA

# Trigger manual workflow_dispatch
#on:
# workflow_dispatch:

# Trigger on push
on:
push:
branches:
- proveedores_qa_pjb

jobs:
build:
runs-on: ubuntu-latest

# Variables de entorno
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME_pjb }}
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN_pjb }}
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: ${{ secrets.DOCKERHUB_USERNAME_pjb }}
password: ${{ secrets.DOCKERHUB_TOKEN_pjb }}

- 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: ${{ secrets.DOCKERHUB_USERNAME_pjb }}/proveedores_qa_pjb:latest


deploy:
needs: build
runs-on: ubuntu-latest

# Variables de entorno
env:
SSH_PRIVATE_KEY: ${{ secrets.PEM_FILE_PAGOS_QA }}
REMOTE_USER: ec2-user
REMOTE_HOST: ${{ vars.PUBLIC_IP_EC2_PROVEEDORES_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 PROVEEDORES_QA || true
sudo docker pull paulajuliabalza/proveedores_qa_pjb:latest
sudo docker run -d --name PROVEEDORES_QA -p 3000:3000 --restart always paulajuliabalza/proveedores_qa_pjb:latest

0 comments on commit ec2f96f

Please sign in to comment.