Skip to content

Commit

Permalink
Updating deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciused26 authored Jan 10, 2025
1 parent 05e8bb0 commit 732587f
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,53 @@
name: Deploy

on:
push:
# push:
# branches: ['develop']
# tags: ['v*.*.*']
pull_request:
branches: ['develop']
tags: ['v*.*.*']
types: [synchronize, closed]

env:
TARGET_DIR: '~/${{ github.event.repository.name }}'

jobs:
docker-hub:
name: Docker Hub Image Push
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
# docker-hub:
# name: Docker Hub Image Push
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v3

- name: Sending Image to Docker Hub
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: victorjorge/gerocuidado-usuario-api
registry: docker.io
directory: ./
dockerfile: ./Dockerfile.prod
tags: latest
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# - name: Sending Image to Docker Hub
# uses: mr-smithers-excellent/docker-build-push@v5
# with:
# image: victorjorge/gerocuidado-usuario-api
# registry: docker.io
# directory: ./
# dockerfile: ./Dockerfile.prod
# tags: latest
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

deploy-ec2:
name: Deploy EC2
needs: docker-hub
runs-on: ubuntu-latest
steps:
- name: Checkout the files
uses: actions/checkout@v2
# deploy-ec2:
# name: Deploy EC2
# needs: docker-hub
# runs-on: ubuntu-latest
# steps:
# - name: Checkout the files
# uses: actions/checkout@v2

- name: Executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST_DNS }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ${{env.TARGET_DIR}}
sudo git pull
sudo docker compose -f docker-compose.prod.yml up --force-recreate --build --pull always --remove-orphans -d
# - name: Executing remote ssh commands using ssh key
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.EC2_HOST_DNS }}
# username: ${{ secrets.EC2_USERNAME }}
# key: ${{ secrets.EC2_SSH_KEY }}
# script: |
# cd ${{env.TARGET_DIR}}
# sudo git pull
# sudo docker compose -f docker-compose.prod.yml up --force-recreate --build --pull always --remove-orphans -d

release:
runs-on: 'ubuntu-latest'
Expand Down

0 comments on commit 732587f

Please sign in to comment.