Deploy to EC2 #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to EC2 | |
on: [workflow_call, 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 | |
sudo systemctl start docker | |
sudo docker stop pontim || true | |
sudo docker rm pontim || true | |
sudo docker pull ${{ secrets.DOCKER_IMAGE }} | |
sudo docker run -d --name pontim -p 80:3000 ${{ secrets.DOCKER_IMAGE }} | |
sudo docker ps | |
sudo docker logs pontim | |
sudo docker image prune -f | |
EOF |