-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ecolink-JOIN/main
[Merge] main -> develop
- Loading branch information
Showing
8 changed files
with
201 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: 'Copy Secrets' | ||
description: 'Copy secret information for server' | ||
inputs: | ||
profile: | ||
description: 'profile which secret belong to' | ||
required: true | ||
oauth-secret: | ||
description: 'oauth secret file' | ||
required: true | ||
s3-secret: | ||
description: 's3 secret file' | ||
required: true | ||
dev-db-secret: | ||
description: 'development db secret file' | ||
prod-db-secret: | ||
description: 'production db secret file' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Copy Oauth and S3 key | ||
env: | ||
OAUTH_SECRET: ${{ inputs.oauth-secret }} | ||
OAUTH_SECRET_DIR_FILE_NAME: application-oauth.yml | ||
S3_SECRET: ${{ inputs.s3-secret }} | ||
S3_SECRET_DIR_FILE_NAME: application-s3.yml | ||
SECRET_DIR: src/main/resources | ||
shell: bash | ||
run: | | ||
echo $OAUTH_SECRET | base64 --decode > $SECRET_DIR/$OAUTH_SECRET_DIR_FILE_NAME | ||
echo $S3_SECRET | base64 --decode > $SECRET_DIR/$S3_SECRET_DIR_FILE_NAME | ||
- name: Copy Dev DB Secrets | ||
if: inputs.profile == 'dev' | ||
env: | ||
DEV_DB_SECRET: ${{ inputs.dev-db-secret }} | ||
DEV_DB_DIR_FILE_NAME: application-dev-db.yml | ||
SECRET_DIR: src/main/resources | ||
shell: bash | ||
run: echo $DEV_DB_SECRET | base64 --decode > $SECRET_DIR/$DEV_DB_DIR_FILE_NAME | ||
|
||
- name: Copy Prod DB Secrets | ||
if: inputs.profile == 'prod' | ||
env: | ||
PROD_DB_SECRET: ${{ inputs.prod-db-secret }} | ||
PROD_DB_SECRET_DIR: src/main/resources | ||
PROD_DB_DIR_FILE_NAME: application-prod-db.yml | ||
SECRET_DIR: src/main/resources | ||
shell: bash | ||
run: echo $PROD_DB_SECRET | base64 --decode > $SECRET_DIR/$PROD_DB_DIR_FILE_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Deploy to Development Server | ||
|
||
on: | ||
push: | ||
branches: [ "develop", "feature/cd/deploy" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'zulu' | ||
|
||
- name: Copy Secrets | ||
uses: ./.github/actions/copy_secret | ||
with: | ||
profile: dev | ||
# oauth-secret: ${{ secrets.OAUTH_SECRET }} | ||
# s3-secret: ${{ secrets.S3_SECRET }} | ||
# dev-db-secret: ${{ secrets.DEV_DB_SECRET }} | ||
|
||
- name: Run MySQL image for test | ||
run: docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=join_db mysql:8.0.31 | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 | ||
with: | ||
arguments: build | ||
|
||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: build-artifacts | ||
path: | | ||
build/libs/*.jar | ||
Dockerfile | ||
docker-compose.yml | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
env: | ||
APP_PATH: ${{ secrets.APP_PATH }} | ||
|
||
steps: | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: build-artifacts | ||
|
||
- name: SCP JAR to EC2 | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USER }} | ||
key: ${{ secrets.EC2_KEY }} | ||
source: "build/libs/*.jar, ./Dockerfile, ./docker-compose.yml" | ||
target: ${{ env.APP_PATH }} | ||
|
||
- name: SSH Execute command on EC2 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USER }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
cd ${{ env.APP_PATH }} | ||
docker-compose down --volumes | ||
docker image prune -f | ||
docker-compose up --build -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Test Build before Merge | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
|
||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'zulu' | ||
|
||
- name: Copy Secrets | ||
uses: ./.github/actions/copy_secret | ||
with: | ||
profile: local | ||
oauth-secret: ${{ secrets.OAUTH_SECRET }} | ||
s3-secret: ${{ secrets.S3_SECRET }} | ||
|
||
- name: Run MySQL image for test | ||
run: docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=join_db mysql:8.0.31 | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 | ||
with: | ||
arguments: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM azul/zulu-openjdk-alpine:17-latest | ||
|
||
WORKDIR /app | ||
|
||
ARG JAR_PATH=./build/libs | ||
|
||
ENV ACTIVE_PROFILE 'dev' | ||
|
||
COPY ${JAR_PATH}/*.jar ${JAR_PATH}/*.jar | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["java","-jar","-Dspring.profiles.active=${ACTIVE_PROFILE}","./build/libs/*.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3.8' | ||
services: | ||
app: | ||
build: . | ||
ports: | ||
- '80:80' | ||
depends_on: | ||
- redis | ||
environment: | ||
- ACTIVE_PROFILE=dev | ||
|
||
redis: | ||
image: redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
spring: | ||
# default host & port is localhost:6379 | ||
data: | ||
redis: | ||
host: redis | ||
port: 6379 | ||
|
||
server: | ||
port: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters