-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.71 KB
/
CD.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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:${{ vars.DOCKER_TAG }} .
- name: Push Docker image
run: docker push almaxgood/cardio-bot:${{ vars.DOCKER_TAG }}
- name: Install sshpass
run: sudo apt install sshpass
- name: Compose .env file
run: |
echo POSTGRES_USER=${{ secrets.POSTGRES_USER }}>>.env
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}>>.env
echo MAIN_TOKEN=${{ secrets.MAIN_TOKEN }}>>.env
echo LOGGER_TOKEN=${{ secrets.LOGGER_TOKEN }}>>.env
echo GUIDE=${{ secrets.GUIDE }}>>.env
echo DOCKER_TAG=${{ vars.DOCKER_TAG }}>>.env
- name: Copy .env file to VM
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.VM_IP }}
username: root
password: ${{ secrets.VM_PASSWORD }}
source: ./.env
target: ~/cardio-bot
- 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'