Merge pull request #200 from DartExplore/issue#199 #41
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
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build with Maven | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '20' | |
- name: Build with Maven | |
run: mvn package -DskipTests | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: app-jar | |
path: target/*.jar | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: app-jar | |
path: target/ | |
- name: Copy files | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.EC2HOSTNAME }} | |
username: ${{ secrets.EC2USERNAME }} | |
key: ${{ secrets.EC2SSH_KEY }} | |
source: "target/*.jar" | |
target: "/home/ubuntu" | |
- name: Restart service | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2HOSTNAME }} | |
username: ${{ secrets.EC2USERNAME }} | |
key: ${{ secrets.EC2SSH_KEY }} | |
script: | | |
sudo systemctl stop my-spring-boot-app.service | |
sudo systemctl start my-spring-boot-app.service |