-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (76 loc) · 2.53 KB
/
compras_qa_manual_v2.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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