Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
w-seok committed Apr 6, 2024
0 parents commit 1e96e8a
Show file tree
Hide file tree
Showing 106 changed files with 4,946 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

[*]
# [encoding-utf8]
charset = utf-8
end_of_line = lf

# [newline-eof]
insert_final_newline = true

[*.bat]
end_of_line = crlf

[*.java]
# [indentation-tab]
indent_style = tab

# [4-spaces-tab]
indent_size = 4
tab_width = 4

# [no-trailing-spaces]
trim_trailing_whitespace = true

[line-length-120]
max_line_length = 120
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.bat text merge=union eol=crlf
* text=auto eol=lf
*.java text eol=lf
120 changes: 120 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: 'People Here Dev Build'

on:
workflow_call:
inputs:
environment:
type: string
required: true
COMMIT_MESSAGE:
type: string
required: true
API_SERVER:
required: true
type: string
STAGE:
required: true
type: string
FORCE_REBUILD:
required: false
type: boolean
outputs:
APP_VERSION:
value: ${{ jobs.build.outputs.APP_VERSION }}
CACHE_KEY:
value: ${{ jobs.build.outputs.CACHE_KEY }}

env:
STAGE: ${{ inputs.STAGE }}
API_SERVER: ${{ inputs.API_SERVER}}
CACHE_KEY: ${{ github.ref }}-${{ inputs.environment }}-${{ github.sha }}

jobs:
build:
name: Build & Test
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
outputs:
APP_VERSION: ${{ steps.app-version.outputs.APP_VERSION }}
CACHE_KEY: ${{ env.CACHE_KEY }}
steps:
- uses: actions/checkout@v4

- name: 버전 세팅
id: app-version
run: |
BUILD_DATE=$(TZ=Asia/Seoul date +'%Y-%m-%d-%H-%M')
case ${BRANCH_NAME} in
"main"|"staging"|"develop")
APP_VERSION="${STAGE:0:1}-${BUILD_DATE}"
;;
"feature/"*)
ISSUE_NAME=$(echo "${BRANCH_NAME}" | sed -n 's/.*\(PH-[0-9]*\).*/\1/p')
APP_VERSION="${ISSUE_NAME}-${BUILD_DATE}"
;;
*)
APP_VERSION="${STAGE}-${{ github.run_id }}"
;;
esac
echo "APP_VERSION=${APP_VERSION}" | tee -a $GITHUB_ENV >> $GITHUB_OUTPUT
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
shell: bash
env:
BRANCH_NAME: ${{ github.ref_name }}
STAGE: ${{ env.STAGE }}

- name: 캐시 재사용 체크
uses: actions/cache/restore@v4
if: inputs.FORCE_REBUILD != true
id: artifact-cache-restore
with:
path: |
.build/jar/*.jar
key: ${{ env.CACHE_KEY }}

- name: 버전정보 캐시정보 출력
run: |
echo "# 앱 버전 APP_VERSION [ ${{ env.APP_VERSION }} ]"
if [ "${{ steps.artifact-cache-restore.outputs.cache-hit }}" == "true" ]; then
echo "### 캐시 ✅ (key: ${{ env.CACHE_KEY }})" >> $GITHUB_STEP_SUMMARY
else
echo "### 캐시 없음 ❎ (key: ${{ env.CACHE_KEY }})" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# java 셋업
- name: Set up JDK 21
if: steps.artifact-cache-restore.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'

# gradle caching
- uses: actions/cache@v4
name: Setup gradle cache
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
${{ runner.os }}-gradle-
- name: API 빌드 - JAR
if: steps.artifact-cache-restore.outputs.cache-hit != 'true'
uses: gradle/gradle-build-action@v3
with:
arguments: -i :module-api:build

- uses: actions/cache/save@v4
if: ${{ steps.artifact-cache-restore.outputs.cache-hit != 'true' && ! endsWith(steps.app-version.outputs.BRANCH_NAME, '/merge') }}
id: artifact-cache
with:
path: |
.build/jar/*.jar
key: ${{ env.CACHE_KEY }}
53 changes: 53 additions & 0 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'People Here API Deploy'

on:
workflow_call:
inputs:
environment:
type: string
required: true
APP_VERSION:
type: string
required: true
CI_BUCKET_NAME:
required: true
type: string
STAGE:
required: true
type: string
JAVA_OPTS:
required: false
type: string
LISTEN_STAGE:
required: true
type: string
CACHE_KEY:
required: true
type: string

permissions:
id-token: write
contents: read

jobs:
build-deploy:
name: 배포용 tar 구성 및 공통스크립트 배포
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: 캐시 불러오기
uses: actions/cache/restore@v3
id: artifact-cache-restore
with:
path: |
.build/jar/*.jar
key: ${{ inputs.CACHE_KEY }}

- name: JAR 배치 - API
run: |
mv .build/jar/api.jar cicd/api/codedeploy/api.jar
- run: ls -al
working-directory: cicd/api/codedeploy
64 changes: 64 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 3. Develop 🚀

on:
workflow_dispatch:
inputs:
deploy-api:
description: Develop API 서버 배포 🎉🤣
type: boolean
required: false
force-rebuild:
description: 강제 빌드
type: boolean
required: false

push:
branches:
- develop
# - 'feature/**'
pull_request:
branches:
- develop

# https://github.com/gradle/gradle-build-action#caching
permissions:
contents: write

# 현재는 develop은 build만 하고 deploy는 stage, production에서만 함
jobs:
build:
name: 빌드 & 테스트
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
uses: ./.github/workflows/build.yml
with:
environment: develop
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
API_SERVER: https://dev.peoplehere.world
STAGE: develop
FORCE_REBUILD: ${{ inputs.force-rebuild == true }}
secrets: inherit

deploy-api:
name: 배포 - API 서버 🚀🚀🚀
needs: [ build ]
if: ${{ contains(github.event.head_commit.message, '#api') || github.event.inputs.deploy-api == 'true' }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
uses: ./.github/workflows/deploy-api.yml
with:
environment: develop
APP_VERSION: ${{ needs.build.outputs.APP_VERSION }}
CI_BUCKET_NAME: aicreation-ci
STAGE: develop
JAVA_OPTS:
LISTEN_STAGE: develop
CACHE_KEY: ${{ needs.build.outputs.CACHE_KEY }}
secrets: inherit


56 changes: 56 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 1. Production

on:
workflow_dispatch:
inputs:
deploy-api:
description: Production API 서버 배포 🎉🤣
type: boolean
required: false
force-rebuild:
description: 강제 빌드
type: boolean
required: false
version-to-upgrade:
description: 배포 버전 업그레이드
type: choice
required: true
options:
- major
- minor
- patch
default: patch

push:
branches:
- main

# https://github.com/gradle/gradle-build-action#caching
permissions:
contents: write

jobs:
build:
name: 빌드 & 테스트
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
uses: ./.github/workflows/build.yml
with:
environment: production
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
API_SERVER: https://prod.peoplehere.world
STAGE: production
FORCE_REBUILD: ${{ inputs.force-rebuild == true }}
secrets: inherit

release:
if: ${{ github.event_name == 'workflow_dispatch' }}
name: 릴리즈
uses: ./.github/workflows/release.yml
with:
environment: production
STAGE: production
CACHE_KEY: ${{ needs.build.outputs.CACHE_KEY }}
VERSION_TO_UPGRADE: ${{ github.event.inputs.version-to-upgrade }}
secrets: inherit
Loading

0 comments on commit 1e96e8a

Please sign in to comment.