2024-09-06 19:08:49 +00:00
|
|
|
name: Deploy Vaadin App
|
2024-09-06 17:41:47 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2024-09-07 14:10:41 +00:00
|
|
|
- prod
|
2024-09-06 17:41:47 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2024-09-06 19:08:49 +00:00
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
2024-09-06 17:41:47 +00:00
|
|
|
|
2024-09-06 19:12:53 +00:00
|
|
|
- name: Set up JDK 22
|
|
|
|
uses: actions/setup-java@v3
|
|
|
|
with:
|
|
|
|
java-version: '22'
|
2024-09-06 19:17:22 +00:00
|
|
|
distribution: 'temurin'
|
2024-09-06 19:12:53 +00:00
|
|
|
|
2024-09-06 19:08:49 +00:00
|
|
|
- name: Build JAR
|
2024-09-06 20:00:43 +00:00
|
|
|
run: ./mvnw clean package -Pproduction -DskipTests
|
2024-09-06 19:20:59 +00:00
|
|
|
|
|
|
|
- name: Set up SSH key
|
|
|
|
uses: webfactory/ssh-agent@v0.5.3
|
|
|
|
with:
|
|
|
|
ssh-private-key: ${{ secrets.SSH_KEY }}
|
2024-09-06 17:41:47 +00:00
|
|
|
|
2024-09-06 19:35:03 +00:00
|
|
|
#- name: Clean deployment directory on server
|
|
|
|
# run: ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'rm -rf /home/${{ secrets.SSH_USER }}/munera/*'
|
2024-09-06 19:31:02 +00:00
|
|
|
|
2024-09-06 19:08:49 +00:00
|
|
|
- name: Upload JAR to server
|
2024-09-06 19:20:59 +00:00
|
|
|
run: scp -o StrictHostKeyChecking=no target/munera-1.0-SNAPSHOT.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
2024-09-06 17:41:47 +00:00
|
|
|
|
2024-09-06 19:08:49 +00:00
|
|
|
- name: Upload Dockerfile to server
|
2024-09-06 19:20:59 +00:00
|
|
|
run: scp -o StrictHostKeyChecking=no Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
2024-09-06 17:48:36 +00:00
|
|
|
|
2024-09-06 19:08:49 +00:00
|
|
|
- name: Upload docker-compose.yml to server
|
2024-09-06 19:20:59 +00:00
|
|
|
run: scp -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera
|
2024-09-06 18:30:32 +00:00
|
|
|
|
2024-09-06 19:31:02 +00:00
|
|
|
- name: Stop Docker containers on server
|
2024-09-06 19:23:34 +00:00
|
|
|
run: ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd /home/${{ secrets.SSH_USER }}/munera && docker-compose down'
|
|
|
|
|
2024-09-06 19:31:02 +00:00
|
|
|
- name: Start Docker containers on server
|
|
|
|
run: |
|
|
|
|
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'ENDSSH'
|
|
|
|
cd /home/${{ secrets.SSH_USER }}/munera
|
|
|
|
docker-compose up --build -d
|
2024-09-06 19:40:33 +00:00
|
|
|
ENDSSH
|