Skip to content

Commit

Permalink
Ci/Cd: EB ci/cd pipeline ๊ตฌ์ถ•
Browse files Browse the repository at this point in the history
  • Loading branch information
yxhwxn committed Jul 9, 2024
1 parent 7704693 commit 345c35a
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .ebextensions_dev/00-makeFiles.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
files:
"/sbin/appstart":
mode: "000755"
owner: webapp
group: webapp
content: |
#!/usr/bin/env bash
JAR_PATH=/var/app/current/application.jar

# run app
killall java
java -Dfile.encoding=UTF-8 -Dspring.profiles.active=dev -jar $JAR_PATH
3 changes: 3 additions & 0 deletions .ebextensions_dev/01-set-timezone.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
commands:
set_time_zone:
command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
85 changes: 85 additions & 0 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: suppin dev CI/CD # Workflow ์ด๋ฆ„

on:
pull_request:
branches:
- dev
types:
- closed
workflow_dispatch: # ์ˆ˜๋™ ์‹คํ–‰๋„ ๊ฐ€๋Šฅํ•˜๋„๋ก

jobs:
build:
runs-on: ubuntu-latest # OS ํ™˜๊ฒฝ ์„ธํŒ…
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' # PR์ด Merge๋˜๊ณ , base branch๊ฐ€ dev์ผ ๋•Œ๋งŒ ์‹คํ–‰

steps:
- name: Checkout
uses: actions/checkout@v2 # .github ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„ ๊ณ„์ธต์˜ ๋ชจ๋“  ์ฝ”๋“œ ํ™•์ธ

# java ์„ค์น˜
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'

# aws ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •
- name: Set Environment
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}

# gradlew ์‹คํ–‰ ๊ถŒํ•œ ๋ถ€์—ฌ
- name: Grant execute permission for gradlew
run: chmod +x gradlew
shell: bash

# ํ…Œ์ŠคํŠธ๋ฅผ ์ œ์™ธํ•œ ๋นŒ๋“œ ์‹œ์ž‘
- name: Build with Gradle
run: ./gradlew build -x test
shell: bash

- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD HH:mm:ss
utcOffset: '+09:00' # build ์‹œ์ ์˜ ์‹œ๊ฐ„์„ ๊ธฐ๋ก

- name: Show current time
run: echo "Current time is ${{ steps.current-time.outputs.time }}"
shell: bash

- name: Generate deployment package
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions_dev deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
# AWS Elastic Beanstalk ๋ฐฐํฌ
- name: BeanStalk Deploy
uses: einaregilsson/beanstalk-deploy@v20
with:
aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}
region: 'ap-northeast-2'
application_name: 'suppin-dev'
environment_name: 'suppin-dev-env'
version_label: github-action-${{ steps.current-time.outputs.formattedTime }}
deployment_package: 'deploy/deploy.zip'
wait_for_deployment: false







1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: appstart

0 comments on commit 345c35a

Please sign in to comment.