-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (55 loc) · 1.69 KB
/
maven.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
57
58
59
60
# 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:
- dev
- master
pull_request:
branches:
- dev
- master
workflow_dispatch:
branches:
- dev
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Set environment variables
if: endsWith(github.ref, 'dev')
run: |
echo "TARGET_HOST=HOST_DEV" >> $GITHUB_ENV
- name : Set environment variables
if: endsWith(github.ref, 'master')
run: |
echo "TARGET_HOST=HOST_PROD" >> $GITHUB_ENV
- name: copy file via ssh key
uses: appleboy/scp-action@master
with:
host: ${{ secrets[env.TARGET_HOST] }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
source: "./target/competition22-1.0-SNAPSHOT-jar-with-dependencies.jar"
target: "/usr/competition22/"
strip_components: 2
- name: Run the jar
uses: appleboy/ssh-action@master
with:
host: ${{ secrets[env.TARGET_HOST] }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: sudo /bin/systemctl restart competition22.service