-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (52 loc) · 1.94 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build the Java service JAR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: maven
- name: Build with Maven
run: mvn package -ntp -B -Pproduction
- uses: actions/upload-artifact@v3
with:
name: pi4j-board-info-service
path: target/pi4j-board-info-service.jar
# Uses approval as described on
# https://trstringer.com/github-actions-manual-approval/
deploy:
name: Deploy to server
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
#- name: Get deployment approval
# uses: trstringer/manual-approval@v1
# with:
# secret: ${{ github.TOKEN }}
# approvers: FDelporte
- name: Download the build output
uses: actions/download-artifact@v2
with:
name: pi4j-board-info-service
- name: List available packages
run: |
ls -la
- name: Upload to production server
run: |
sshpass -p '${{ secrets.SERVER_PASSWORD }}' scp -o StrictHostKeyChecking=no pi4j-board-info-service.jar ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_ADDRESS }}:${{ secrets.SERVER_LOCATION }}
- name: Restart the service on the production server
run: |
sshpass -p '${{ secrets.SERVER_PASSWORD }}' ssh -t ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_ADDRESS }} 'sudo systemctl restart pi4j_board_info.service'