-
Notifications
You must be signed in to change notification settings - Fork 15
45 lines (37 loc) · 1.35 KB
/
deploy.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
name: Deploy to EC2
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx (optional for caching)
uses: docker/setup-buildx-action@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
deploy:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Install SSH client
run: sudo apt-get install -y sshpass
- name: SSH and deploy
env:
SSHPASS: ${{ secrets.EC2_KEY }}
run: |
sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
# Clonar el repositorio en una ruta específica
git clone https://github.com/Trycatch-tv/ValidadorBootcamp-backend /home/${{ secrets.EC2_USER }}/app
cd /home/${{ secrets.EC2_USER }}/app
# Actualizar la imagen del servicio backend y reiniciarlo sin afectar db
docker-compose down
docker-compose up -d --no-deps --build
EOF