Skip to content

Commit

Permalink
Merge pull request #38 from ItaloMedici/develop
Browse files Browse the repository at this point in the history
Add deploy ec2
  • Loading branch information
ItaloMedici authored Jan 26, 2025
2 parents 253a0ba + b15c318 commit f66213c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy to EC2

on:
workflow_run:
workflows:
- Build and Publish Docker Image
types:
- completed
workflow_dispatch:

jobs:
deploy:
name: Deploy to EC2
runs-on: ubuntu-latest

steps:
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
docker pull ${{ secrets.DOCKER_IMAGE }}
docker stop pontim || true
docker rm pontim || true
docker run -d --name pontim -p 80:3000 ${{ secrets.DOCKER_IMAGE }}
docker image prune -f
EOF

0 comments on commit f66213c

Please sign in to comment.