-
Notifications
You must be signed in to change notification settings - Fork 2
114 lines (99 loc) · 4.12 KB
/
gradle.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on: #이벤트 감지
pull_request:
types: [closed]
workflow_dispatch:
env:
LIGHTSAIL_SSH_KEY: ${{ secrets.LIGHTSAIL_SSH_KEY }}
LIGHTSAIL_HOST: ${{ secrets.LIGHTSAIL_HOST }}
LIGHTSAIL_USERNAME: ubuntu
AWS_REGION: ap-northeast-2
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps: # STEP BY STEP 실행
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: build
#jar 실행파일생성
- name: Build the *.jar executable as Gradle
uses: actions/upload-artifact@v2
with:
name: jarfile
path: build/libs/community-0.0.1-SNAPSHOT.jar
#파일 여부확인
- name: checkout file list
run: ls
#AWS에 접속한다.
- name: Access AWS
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
#AWS 인증으 우선 실시항 접소 가능ㅎ 사용자인지 확인
- name: Check the connection status of AWS Lightsail
run: aws configure list
# 배포 자동화를 시작합니다.
- name: Move executable files from GitHub's virtual environment
uses: appleboy/scp-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{env.LIGHTSAIL_USERNAME}}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
source: build/libs/*
strip_components: 1
target: '/home/ubuntu'
- name: Stop the running server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{env.LIGHTSAIL_USERNAME}}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: ./stop.sh
- name: make start.sh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{env.LIGHTSAIL_USERNAME}}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: echo -e "#!/bin/bash\n
export JWT_SECRET=${{ secrets.JWT_SECRET }}\n
export DB_URL=${{ secrets.DB_URL }}\n
export DB_USERNAME=${{ secrets.DB_USERNAME }}\n
export DB_PASSWORD=${{ secrets.DB_PASSWORD }}\n
export GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}\n
export GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}\n
export GOOGLE_GRANT_TYPE=${{ secrets.GOOGLE_GRANT_TYPE }}\n
export GOOGLE_REDIRECT_URI=${{ secrets.GOOGLE_REDIRECT_URI }}\n
nohup java -jar ./libs/community-0.0.1-SNAPSHOT.jar > /home/ubuntu/RETURN.log 2>&1 &" > start.sh
- name: Grant execute permission for start.sh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{env.LIGHTSAIL_USERNAME}}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: chmod +x start.sh
- name: Start server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.LIGHTSAIL_HOST }}
username: ${{env.LIGHTSAIL_USERNAME}}
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
script: ./start.sh