feat: CD #1
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: Continuous Deployment | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Authorize in Docker | |
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set up JDK 20 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '20' | |
distribution: 'adopt' | |
- name: Build JAR | |
run: ./gradlew bootJar | |
- name: Build Docker image | |
run: docker build --platform linux/amd64 -t almaxgood/cardio-bot:1.0.0 . | |
- name: Push Docker image | |
run: docker push almaxgood/cardio-bot:1.0.0 | |
- name: Install sshpass | |
run: sudo apt install sshpass | |
- name: Run on VM | |
run: sshpass -p ${{ secrets.VM_PASSWORD }} ssh -o StrictHostKeyChecking=no root@${{ secrets.VM_IP }} | |
'cd ~/cardio-bot && | |
docker compose down && | |
docker system prune -a -f --volumes && | |
docker compose up -d' |