Skip to content

Connect Pull and Deploy #3

Connect Pull and Deploy

Connect Pull and Deploy #3

Workflow file for this run

name: Connect Pull and Deploy
on:
push:
branches: ["main"]
schedule:
- cron: "25 13 * * *" # Daily at 3:00 PM UTC
jobs:
docker-login:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Deploy to Ec2 instance
uses: appleboy/ssh-action@master
with:
host: ${{secrets.EC2_HOST}}
username: ${{secrets.EC2_USERNAME}}
key: ${{secrets.EC2_PRIVATE_KEY}}
script: |
sudo docker stop cabmanagement || true
sudo docker rm cabmanagement || true
sudo docker rmi notprasanna/versavolt:cab-image-latest
sudo docker ps
sudo docker pull notprasanna/versavolt:cab-image-latest
sudo docker images
sudo docker run -d -p 8080:8080 --network springbootapi --name cabmanagement notprasanna/versavolt:cab-image-latest
sudo docker start cabmanagement
sudo docker ps