-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (56 loc) · 1.98 KB
/
cicd.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
name: Java CI/CD for Develop Server
on:
push:
branches: [ "release/dev" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Retrieve secrets
env:
MY_PROPERTIES_ARCHIVE: ${{ secrets.DEV_APPLICATION_SECRETS }}
MY_S3CONFIG_ARCHIVE: ${{ secrets.DEV_S3CONFIG }}
run: |
echo "$MY_PROPERTIES_ARCHIVE" | base64 --decode > secrets.tar.gz
tar xzvf secrets.tar.gz -C src/main/resources
echo "$MY_S3CONFIG_ARCHIVE" | base64 --decode > s3config.tar.gz
tar xzvf s3config.tar.gz -C src/main/java/com/newfit/reservation/common/config
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run : ./gradlew clean build --exclude-task test
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: cicdsample
path: build/libs/reservation-0.0.1-SNAPSHOT.jar
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: cicdsample
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add remote server to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
- name: SCP transfer
run: scp *.jar ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:~/
- name: Execute remote commands
run: |
ssh -vv ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "fuser -k 8080/tcp || true"
ssh -vv ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "nohup java -jar reservation-0.0.1-SNAPSHOT.jar > nohup.log 2>&1 &"