Skip to content

Update CD.yml

Update CD.yml #2

Workflow file for this run

name: CD
on:
push:
branches: [ "main" ]
jobs:
CD:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
cache: maven
- name: Build The Application
run: mvn -B -f pom.xml clean install -Dmaven.test.skip=true
- name: Configure SSH Azure
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/remote.key
chmod 600 ~/.ssh/remote.key
cat >>~/.ssh/config <<END
Host remote
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/azure.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_KEY: ${{ secrets.SSH_KEY }}
- name: Deploy The Application
run: |
ssh remote 'sudo rm -rf /api/java-api.jar'
scp target/java-api.jar remote:/api/java-api.jar