Perform Action once a week #15
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: Connect Pull and Deploy | |
on: | |
push: | |
branches: ["main"] | |
schedule: | |
- cron: "25 13 * * 1" # 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 |