-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
290 additions
and
118 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,61 @@ | ||
# 최신 Tag 기준으로 Hotfix Branch 생성 | ||
name: Create Hotfix Branch | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
artifact: | ||
type: choice | ||
description: 'artifact type' | ||
required: true | ||
default: 'Api' | ||
options: | ||
- 'Api' | ||
- 'Batch' | ||
|
||
jobs: | ||
create-branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.MY_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
# 최신 Tag 가져오기 | ||
- name: Get latest tag | ||
id: get-latest-tag | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0 --match "${{ github.event.inputs.artifact }}-v*") | ||
echo "LATEST_TAG=$latest_tag" >> $GITHUB_OUTPUT | ||
# Hotfix 용 버전 생성 | ||
- name: Create new hotfix version | ||
id: create-new-version | ||
run: | | ||
tag=${{ steps.get-latest-tag.outputs.LATEST_TAG }} | ||
IFS='+' read -ra version_parts <<< "$tag" | ||
version=${version_parts[0]} | ||
fix_number=${version_parts[1]} | ||
# 픽스넘버가 비어 있는 경우 0으로 설정 | ||
if [ -z "$fix_number" ]; then | ||
fix_number=0 | ||
fi | ||
# 픽스넘버 증가 | ||
fix_number=$((fix_number + 1)) | ||
# hotfix 버전 | ||
new_version="${version}+${fix_number}" | ||
echo "NEW_VERSION=$new_version" >> $GITHUB_OUTPUT | ||
# tag 기반 Hotfix Branch 생성 | ||
- name: Create and push hotfix branch | ||
run: | | ||
tag=${{ steps.get-latest-tag.outputs.LATEST_TAG }} | ||
git checkout -b hotfix/${{ steps.create-new-version.outputs.NEW_VERSION }} tags/$tag | ||
git push origin hotfix/${{ steps.create-new-version.outputs.NEW_VERSION }} |
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,69 @@ | ||
# 새로운 버전의 Release Branch 생성 | ||
name: Create Release Branch | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
artifact: | ||
type: choice | ||
description: 'artifact type' | ||
required: true | ||
default: 'Api' | ||
options: | ||
- 'Api' | ||
- 'Batch' | ||
version-up: | ||
type: choice | ||
description: 'version up type' | ||
required: true | ||
default: 'patch' | ||
options: | ||
- 'major' | ||
- 'minor' | ||
- 'patch' | ||
|
||
jobs: | ||
create-branch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.MY_TOKEN }} | ||
fetch-depth: 0 | ||
|
||
# 최신 Tag 가져오기 | ||
- name: Get latest tag | ||
id: get-latest-tag | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0 --match "${{ github.event.inputs.artifact }}-v*" 2>/dev/null || echo "") | ||
echo "LATEST_TAG=$latest_tag" >> $GITHUB_OUTPUT | ||
# 최신 Tag 기준으로 버전 업데이트 | ||
- name: Version up | ||
id: version-up | ||
run: | | ||
latest_tag=${{ steps.get-latest-tag.outputs.LATEST_TAG }} | ||
if [ -z "$latest_tag" ]; then | ||
new_version="1.0.0" | ||
else | ||
version=$(echo $latest_tag | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}') | ||
if [ ${{ github.event.inputs.version-up }} == "major" ]; then | ||
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1 + 1, 0, 0}') | ||
elif [ ${{ github.event.inputs.version-up }} == "minor" ]; then | ||
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1, $2 + 1, 0}') | ||
else | ||
new_version=$(echo $version | awk -F'.' '{printf "%d.%d.%d", $1, $2, $3 + 1}') | ||
fi | ||
fi | ||
echo "NEW_VERSION=$new_version" >> $GITHUB_OUTPUT | ||
# 새 버전 Release Branch 생성 | ||
- name: Create and push release branch | ||
run: | | ||
new_version=${{ steps.version-up.outputs.NEW_VERSION }} | ||
git checkout -b release/${{ github.event.inputs.artifact}}-v$new_version | ||
git push origin release/${{ github.event.inputs.artifact}}-v$new_version |
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,64 @@ | ||
# API - Dev Server에 배포 | ||
name: API - Deploy Development Environment | ||
|
||
on: | ||
create: | ||
push: | ||
branches: | ||
- release/Api-v* | ||
- hotfix/Api-v* | ||
|
||
jobs: | ||
check-branch: | ||
# Branch 이름 가져오기 | ||
if: ${{ github.event_name != 'create' || github.ref_type != 'tag' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current_branch: ${{ steps.branch-name.outputs.current_branch }} | ||
steps: | ||
- name: Get branch name | ||
id: branch-name | ||
uses: tj-actions/branch-names@v8 | ||
|
||
deploy-development-environment: | ||
needs: check-branch | ||
# release, hotfix 일때만 실행 | ||
if: startsWith(${{ needs.check-branch.outputs.current_branch}}, 'release/Api-v') || startsWith(${{ needs.check-branch.outputs.current_branch}}, 'hotfix/Api-v') | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.MY_TOKEN }} | ||
submodules: true | ||
|
||
# JDK 환경 셋팅 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: '17' | ||
cache: gradle | ||
|
||
# Gradle Permission | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
# Build | ||
- name: Gradle build | ||
run: | | ||
./gradlew globalCopyConfig | ||
./gradlew adevspoon-api:build -x test | ||
# AWS Config | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
# Deploy to Lambda | ||
- name: Deploy to lambda | ||
run: | | ||
# aws lambda update-function-code --function-name adevspoon-api --zip-file fileb://adevspoon-api/build/libs/adevspoon-api-*.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
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,47 @@ | ||
# Tag 생성 및 Release 생성 | ||
name: Versioning - Tagging and Release | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
types: | ||
- closed | ||
|
||
jobs: | ||
check-branch: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
current_branch: ${{ steps.branch-name.outputs.current_branch }} | ||
steps: | ||
- name: Get branch names | ||
id: branch-name | ||
uses: tj-actions/branch-names@v8 | ||
|
||
# Release 또는 Hotfix 브랜치가 merge 될때 실행 | ||
tagging-and-release: | ||
needs: check-branch | ||
runs-on: 'ubuntu-latest' | ||
if: github.event.pull_request.merged == true && (startsWith(${{ needs.check-branch.outputs.current_branch }}, 'release/') || startsWith(${{ needs.check-branch.outputs.current_branch }}, 'hotfix/')) | ||
steps: | ||
- name: Get tag | ||
id: get-tag | ||
run: | | ||
branch=${{ needs.check-branch.outputs.current_branch }} | ||
new_tag="${branch#release/}" | ||
new_tag="${new_tag#hotfix/}" | ||
echo "NEW_TAG=$new_tag" >> $GITHUB_OUTPUT | ||
- name: Check tag | ||
run: | | ||
echo ${{ steps.get-tag.outputs.NEW_TAG }} | ||
- name: Create Release & Tag | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.MY_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.get-tag.outputs.NEW_TAG }} | ||
release_name: ${{ steps.get-tag.outputs.NEW_TAG }} | ||
body: | | ||
${{ github.event.pull_request.body }} |
Oops, something went wrong.