-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (58 loc) · 2.45 KB
/
main.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
61
62
63
64
65
66
67
name: authentication-configuration-jar
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Extract Project version
id: project
run: echo ::set-output name=version::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
- name: Build JAR
run: |
mvn clean install
working-directory: /home/runner/work/authentication-configuration-jar/authentication-configuration-jar
- name: Set Up SSH Key
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts
env:
SSH_PRIVATE_KEY: ${{secrets.V4_VPS_PRIVATE_KEY}}
HOST: ${{secrets.V4_HOST}}
PROJECT_VERSION: ${{steps.project.outputs.version}}
- name: Create Directory
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.V4_HOST }}
username: ${{ secrets.V4_USERNAME }}
key: ${{ secrets.V4_VPS_PRIVATE_KEY }}
PROJECT_VERSION: ${{steps.project.outputs.version}}
port: 22
script: |
mkdir -p /var/www/spring-repo/com/bloggios/authentication-config/authentication-configuration-jar
cd /var/www/spring-repo/com/bloggios/authentication-config/authentication-configuration-jar
rm ${{steps.project.outputs.version}} -r
mkdir ${{steps.project.outputs.version}}
- name: Copy JAR to VPS
run: |
pwd
scp -i ~/.ssh/id_rsa /home/runner/work/authentication-configuration-jar/authentication-configuration-jar/target/*.jar "$VPS_SERVER_USERNAME@$VPS_SERVER_IP:$VPS_SERVER_DESTINATION_DIR/$PROJECT_VERSION"
env:
VPS_SERVER_IP: ${{ secrets.V4_HOST }}
VPS_SERVER_USERNAME: ${{ secrets.V4_USERNAME }}
VPS_SERVER_DESTINATION_DIR: /var/www/spring-repo/com/bloggios/authentication-config/authentication-configuration-jar
PROJECT_VERSION: ${{steps.project.outputs.version}}