Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/deploy-admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
- develop
paths:
- 'application-admin/**'
- 'application-config/**'
- 'common/**'
- 'domain-*/**'
- 'application-config/**'
- 'security-admin/**'
- 'infra-aws/**'
- 'build.gradle'
- 'settings.gradle'
- 'gradle/**'
Expand Down Expand Up @@ -41,9 +42,7 @@ jobs:
- name: Set YML
run: |
mkdir -p application-admin/src/main/resources
echo "${{ secrets.APPLICATION_DEV_ADMIN_YML }}" \
| base64 --decode \
> application-admin/src/main/resources/application-admin.yml
echo "${{ secrets.APPLICATION_DEV_ADMIN_YML }}" | base64 --decode application-admin/src/main/resources/application-admin.yml
find application-admin/src

- name: Build Admin JAR
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/deploy-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Dev User CI/CD

on:
push:
branches:
- develop
paths:
- 'application-user/**'
- 'application-config/**'
- 'common/**'
- 'domain-*/**'
- 'security-front/**'
- 'external-oauth/**'
- 'build.gradle'
- 'settings.gradle'
- 'gradle/**'

env:
PROJECT_NAME: NoWait
DIVISION: user
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: nowait-deploy-github-actions
AWS_CODE_DEPLOY_APPLICATION: nowaiting
AWS_CODE_DEPLOY_GROUP: nowaiting-deploy-dev-user

jobs:
build-with-gradle:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew

- name: Set YML
run: |
mkdir -p application-user/src/main/resources
echo "${{ secrets.APPLICATION_DEV_USER_YML }}" | base64 --decode application-user/src/main/resources/application-user.yml
find application-user/src

- name: Build User JAR
run: ./gradlew clean :application-user:bootJar -x test

- name: Prepare deployment package
run: |
rm -rf deploy
mkdir -p deploy/scripts
cp scripts/start-admin.sh scripts/stop-admin.sh deploy/scripts/
cp appspec-admin.yml deploy/appspec.yml
cp application-admin/build/libs/application-admin-*.jar deploy/application-admin.jar
cd deploy
zip -r ../NoWait-admin-${GITHUB_SHA}.zip .
cd ..

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.DEVSERVER_CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.DEVSERVER_CICD_SECRET_KEY }}

- name: Upload to S3
run: |
aws deploy push \
--application-name "${{ env.AWS_CODE_DEPLOY_APPLICATION }}" \
--ignore-hidden-files \
--s3-location "s3://${{ env.AWS_S3_BUCKET }}/${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip" \
--source deploy

- name: Create CodeDeploy deployment
run: |
aws deploy create-deployment \
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} \
--s3-location bucket=${{ env.AWS_S3_BUCKET }},key=${{ env.PROJECT_NAME }}/${{ env.DIVISION }}/${{ github.sha }}.zip,bundleType=zip


Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ public static void main(String[] args) {
org.springframework.boot.SpringApplication.run(ApiAdminApplication.class, args);
}
}

20 changes: 20 additions & 0 deletions appspec-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/spring-github-action-user
overwrite: yes

permissions:
- object: /
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop-user.sh
timeout: 60
ApplicationStart:
- location: scripts/start-user.sh
timeout: 60
12 changes: 6 additions & 6 deletions scripts/start-user.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash

REPOSITORY="/home/ubuntu/spring-github-action"
REPOSITORY="/home/ubuntu/spring-github-action-user"
cd $REPOSITORY

APP_NAME=application-admin
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME
APP_NAME=application-user
JAR_NAME=$(ls $REPOSITORY | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/$JAR_NAME

START_LOG="$REPOSITORY/start.log"
ERROR_LOG="$REPOSITORY/error.log"
APP_LOG="$REPOSITORY/application.log"

$ chmod 666 $START_LOG
$ chmod 666 ERROR_LOG
$ chmod 666 APP_LOG
$ chmod 666 $ERROR_LOG
$ chmod 666 $APP_LOG

SERVICE_PID=$(pgrep -f ${APP_NAME}.*.jar) # 실행중인 Spring 서버의 PID
NOW=$(date +%c)
Expand Down
10 changes: 5 additions & 5 deletions scripts/stop-user.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

REPOSITORY=/home/ubuntu/spring-github-action
REPOSITORY="/home/ubuntu/spring-github-action-user"
cd $REPOSITORY

APP_NAME=application-admin
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME
APP_NAME=application-user
JAR_NAME=$(ls $REPOSITORY | grep '.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/$JAR_NAME
STOP_LOG="$REPOSITORY/stop.log"

$ chmod 666 STOP_LOG
$ chmod 666 "$STOP_LOG"

CURRENT_PID=$(pgrep -f ${APP_NAME}.*.jar)

Expand Down