name: Deploy Vaadin App on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up JDK 22 uses: actions/setup-java@v3 with: java-version: '22' distribution: 'temurin' - name: Build JAR run: ./mvnw clean package -DskipTests - name: Set up SSH key uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SSH_KEY }} - name: Clean deployment directory on server run: ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'rm -rf /home/${{ secrets.SSH_USER }}/munera/*' - name: Upload JAR to server run: scp -o StrictHostKeyChecking=no target/munera-1.0-SNAPSHOT.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera - name: Upload Dockerfile to server run: scp -o StrictHostKeyChecking=no Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera - name: Upload docker-compose.yml to server run: scp -o StrictHostKeyChecking=no docker-compose.yml ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera - name: Stop Docker containers on server run: ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd /home/${{ secrets.SSH_USER }}/munera && docker-compose down' - name: Start Docker containers on server env: DB_ADDRESS: ${{ secrets.DB_ADDRESS }} DB_USER: ${{ secrets.DB_USER }} DB_PASSWORD: ${{ secrets.DB_PASSWORD }} DB_NAME: ${{ secrets.DB_NAME }} run: | ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'ENDSSH' cd /home/${{ secrets.SSH_USER }}/munera docker-compose up --build -d ENDSSH