Added an extra space #25
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
# Deploys to an Azure Virtual Machine and starts the web app | ||
name: Deploy Java app to Azure Virtual Machine | ||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
types: [ closed ] | ||
jobs: | ||
deploy: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml | ||
- name: Create SSH key file | ||
# Write private key to .pem file | ||
run: echo "${{ secrets.SPRING_BOOT_VM_PRIVATE_KEY }}" > private_key.pem | ||
- name: Deploy to Azure Virtual Machine | ||
env: | ||
SPRING_BOOT_VM_IP: ${{ secrets.SPRING_BOOT_VM_IP }} | ||
SPRING_BOOT_VM_USERNAME: ${{ secrets.SPRING_BOOT_VM_USERNAME }} | ||
run: | | ||
# Add host to known hosts | ||
ssh-keyscan -H ${{ secrets.SPRING_BOOT_VM_IP }} >> ~/.ssh/known_hosts | ||
# Transfer artifact using scp | ||
scp -v -o "StrictHostKeyChecking=no" -i private_key.pem target/*.jar $SPRING_BOOT_VM_USERNAME@$SPRING_BOOT_VM_IP:/home/$SPRING_BOOT_VM_USERNAME/spring_boot_demo/ |