Skip to content

Commit

Permalink
deploy ec2
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriqueAmorim20 committed Oct 24, 2023
1 parent 57a2cd3 commit ceea5a2
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ on:
branches: ['CD_test_branch']
tags: ['v*.*.*']

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

jobs:
deploy:
name: Docker Hub
docker-hub:
name: Docker Hub Image Push
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand All @@ -23,3 +26,23 @@ jobs:
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

- 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}}
git checkout CD_test_branch
git pull
docker-compose -f docker-compose.prod.yml up -V --force-recreate --build -d

0 comments on commit ceea5a2

Please sign in to comment.