Cloud Dev 1st CI FE - 100-hours-a-week/KTB4-1st-wiki GitHub Wiki
2๋จ๊ณ. CI(์ง์์ ํตํฉ) ํ์ดํ๋ผ์ธ ์ค๊ณ์์ ์ ํ CI Trigger๋ฅผ KTB4-1st-FE ๋ ํฌ์ ์ค์ ๋ก ๊ตฌํํ ๋ด์ฉ์ด๋ค.
- ๋์ ๋ ํฌ:
KTB4-1st-FE - ์ํฌํ๋ก์ฐ ํ์ผ:
fe-pr-check.yml,fe-docker-publish.yml
| ํ์ผ | ํธ๋ฆฌ๊ฑฐ | ์คํ ํญ๋ชฉ |
|---|---|---|
fe-pr-check.yml |
feat โ dev, hotfix โ main PR |
ESLint ์ ์ ๋ถ์, ๋น๋(npm run build), Docker Image ๋น๋(push ์์) |
fe-docker-publish.yml |
dev push(merge) |
Docker Image ๋น๋ + GHCR push (latest, dev-<short SHA>) |
fe-docker-publish.yml |
release ํ๊ทธ(v*.*.*) push |
Docker Image ๋น๋ + GHCR push (Semantic Version) |
name: FE CI - PR Check
# feat -> dev PR, hotfix -> main PR: ์ ์ ๋ถ์, (๋จ์ ํ
์คํธ - ํ
์คํธ ์ฝ๋ ์์ด ํ์ฌ ์ ์ธ), ๋น๋, Docker Image ๋น๋(push ์์)
on:
pull_request:
branches:
- dev
- main
paths:
- "ktb_agile_frontend/**"
- ".github/workflows/fe-pr-check.yml"
# ๋์ผ PR์ ์ฐ์ Push ๋ฐ์ ์ ์งํ ์ค์ด๋ ์ด์ ์คํ ์๋ ์ทจ์
concurrency:
group: fe-pr-check-${{ github.event.pull_request.number }}
cancel-in-progress: true
defaults:
run:
working-directory: ktb_agile_frontend
jobs:
verify:
name: ์ ์ ๋ถ์ ๋ฐ ๋น๋
runs-on: ubuntu-latest
steps:
- name: Checkout # ์์ค ์ฝ๋ ๋ค์ด๋ก๋
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "24.21.0"
cache: npm
cache-dependency-path: ktb_agile_frontend/package-lock.json
- name: ์์กด์ฑ ์ค์น
run: npm ci
- name: ์ ์ ๋ถ์ (ESLint)
run: npm run lint
# ๋จ์ ํ
์คํธ - ํ์ฌ ํ
์คํธ ์ฝ๋๊ฐ ์์ด ์๋ต
- name: ๋น๋
run: npm run build
docker-build:
name: Docker Image ๋น๋ (๊ฒ์ฆ์ฉ, push ์์)
needs: verify
# ARM64 ์ ์ฉ GitHub Hosted ๋ฌ๋ ์ฌ์ฉ
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Docker Image ๋น๋ (push ์์)
uses: docker/build-push-action@v7
with:
context: ktb_agile_frontend # ๋น๋ ์ปจํ
์คํธ ๊ฒฝ๋ก
push: false
tags: ktb4-1st-fe:pr-${{ github.event.pull_request.number }}
์ธ๋ถ ๊ฒฐ์ ์ฌํญ
- ์ ์ ๋ถ์: ESLint โ ํ์ -๊ฐ์ด๋-v1์์ Next.js ํํธ์ CI ํ์ง ๊ฒ์ดํธ ๋๊ตฌ๋ก ์ง์ ๋จ
-
๋น๋:
npm run build - ๋จ์ ํ ์คํธ ์ ์ธ - ํ์ฌ ํ ์คํธ ์ฝ๋๊ฐ ์์ด ์๋ต
- PR ๋จ๊ณ Docker ๋น๋๋ push ์ ํจ - PR์ merge๊ฐ ๊ฑฐ์ ๋์ด ์ฝ๋๊ฐ ๋ฐ๋ ์ ์์ผ๋ฏ๋ก, ๋น๋ ์ฑ๊ณต ์ฌ๋ถ๋ง ํ์ธํ๊ณ ๋ ์ง์คํธ๋ฆฌ์๋ ์ฌ๋ฆฌ์ง ์์
name: FE Docker Image Publish
# dev push(merge): Docker Image ๋น๋ ๋ฐ GHCR(100-hours-a-week ์กฐ์ง ์์ ํจํค์ง) Push
# - latest(๋ก์ปฌ ํ
์คํธ์ฉ ํฌ์ธํฐ), dev-<short SHA>(๋ถ๋ณ ์ถ์ ์ฉ) ํ๊ทธ
# release tag(v*.*.*) push: ๋ฐฐํฌ์ฉ Docker Image ๋น๋ ๋ฐ GHCR Push
# - main์ผ๋ก dev/hotfix๊ฐ merge๋ ๋ค, ๋ฆด๋ฆฌ์ฆ ๋ด๋น์๊ฐ ํด๋น ์ปค๋ฐ์ Semantic Version ํ๊ทธ(์: v1.0.1)๋ฅผ pushํ๋ฉด ํธ๋ฆฌ๊ฑฐ๋จ
# - Semantic Version ํ๊ทธ(v ์ ๋์ด ์ ์ธ)๋ง ์ด๋ฏธ์ง ํ๊ทธ๋ก ์ฌ์ฉ
on:
push:
branches:
- dev
tags:
- "v*.*.*"
paths:
- "ktb_agile_frontend/**"
- ".github/workflows/fe-docker-publish.yml"
# ๋์ผ ๋ธ๋์น/ํ๊ทธ์ ์ฐ์ Push ๋ฐ์ ์ ์งํ ์ค์ด๋ ์ด์ ์คํ ์๋ ์ทจ์
concurrency:
group: fe-docker-publish-${{ github.ref }} # dev์ pushํ๋ฉด refs/heads/dev, ํ๊ทธ pushํ๋ฉด refs/tags/v1.0.1
cancel-in-progress: true
env:
REGISTRY: ghcr.io
# github.repository๋ "100-hours-a-week/KTB4-1st-FE" ํํ(docker/metadata-action์ด images ๊ฐ์ ์๋์ผ๋ก ์๋ฌธ์ ๋ณํ)
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Docker Image ๋น๋ ๋ฐ GHCR Push
# ARM64 ์ ์ฉ GitHub Hosted ๋ฌ๋ ์ฌ์ฉ
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Docker ๋ฉํ๋ฐ์ดํฐ(ํ๊ทธ/๋ผ๋ฒจ) ์์ฑ
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# dev : latest(๋ก์ปฌ ํ
์คํธ์ฉ ํฌ์ธํฐ), dev-<short SHA>(๋ถ๋ณ ์ถ์ ์ฉ)
# release tag : push๋ ํ๊ทธ(v1.0.1)์์ v๋ฅผ ๋ Semantic Version์ ๊ทธ๋๋ก ํ๊ทธ๋ก ์ฌ์ฉ
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha,format=short,prefix=dev-,enable=${{ github.ref == 'refs/heads/dev' }}
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.authors=${{ github.actor }}
- name: Docker Image ๋น๋ ๋ฐ Push
id: build-push
run: |
set -e
# ํ๊ทธ ๋ณํ
TAG_ARGS=()
while IFS= read -r tag; do
[ -z "$tag" ] && continue
TAG_ARGS+=(--tag "$tag")
done <<< "${{ steps.meta.outputs.tags }}"
# ๋ผ๋ฒจ ๋ณํ
LABEL_ARGS=()
while IFS= read -r label; do
[ -z "$label" ] && continue
LABEL_ARGS+=(--label "$label")
done <<< "${{ steps.meta.outputs.labels }}"
# ์ด๋ฏธ์ง ๋น๋ + GHCR push
docker buildx build \
--push \
"${TAG_ARGS[@]}" \
"${LABEL_ARGS[@]}" \
./ktb_agile_frontend
์ธ๋ถ ๊ฒฐ์ ์ฌํญ
-
dev ํ๊ทธ:
latest(๋ก์ปฌ ํ ์คํธ์ฉ ํฌ์ธํฐ),dev-<short SHA>(๋ถ๋ณ ์ถ์ ์ฉ) -
main ๋ฐฐํฌ ๋ฒ์ = Git tag ๊ธฐ๋ฐ Semantic Version
- ์ฒ์์๋
package.json์version๊ฐ์ ์ฝ์ด ํ๊ทธ๋ก ์ฐ๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ์์ผ๋, AI ๋ ํฌ์ ๋ฒ์ ๊ด๋ฆฌ ๋ฐฉ์์ ํต์ผํ๊ธฐ ์ํด Git tag(v*.*.*) push ๊ธฐ์ค์ผ๋ก ๋ณ๊ฒฝํ๋ค. (์๋ "์ค๊ณ ๋ฌธ์์ ๋ฌ๋ผ์ง ์ " ์ฐธ๊ณ ) -
docker/metadata-action์type=semver,pattern={{version}}์ด push๋ ํ๊ทธ(์:v1.0.1)์์v์ ๋์ด๋ฅผ ๋1.0.1์ ์๋์ผ๋ก ์ด๋ฏธ์ง ํ๊ทธ๋ก ์ถ์ถ - main์ผ๋ก ๋ณํฉ๋ง ํด์๋ ์ด๋ฏธ์ง๊ฐ ๋ง๋ค์ด์ง์ง ์๋๋ค. ๋ฐ๋์ ํ๊ทธ๋ฅผ pushํด์ผ ํธ๋ฆฌ๊ฑฐ๋๋ค.
- ์ฒ์์๋
-
๋ฆด๋ฆฌ์ฆ ์ ์ฐจ (dev/hotfix โ main PR merge ์ดํ)
- GitHub ์ ์ฅ์ โ Releases โ Create a new release
- Target:
main, ์ ํ๊ทธ๋ฅผv1.0.1ํ์์ผ๋ก ์ ๋ ฅ ํ ์์ฑ - Publish release ํด๋ฆญ โ ํ๊ทธ๊ฐ push๋์ด ์ํฌํ๋ก์ฐ๊ฐ ์๋ ์คํ๋จ
- CLI๋ก
git tag/git pushํด๋ ๋์ผํ๊ฒ ๋์ํ์ง๋ง, GitHub Release ์ชฝ์ด CLI ์์ด ๋ธ๋ผ์ฐ์ ์์ ๋๋๊ณ ๋ฆด๋ฆฌ์ฆ ๋ ธํธ๋ ํจ๊ป ๋จ์ ์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ธฐ๋ก ๊ฒฐ์ ํจ
-
๋ผ๋ฒจ ์์ฑ์ ์ ๋ณด -
github.event.head_commit.author.name๋์github.actor๋ฅผ ์ฌ์ฉ- Annotated tag๋ฅผ pushํ๋ ์ด๋ฒคํธ์์๋
head_commit์ด ๋น์ด ์์ ์ ์์ด(GitHub ์นํ ํน์ฑ), ํญ์ ๊ฐ์ด ์ฑ์์ง๋github.actor(ํ๊ทธ๋ฅผ pushํ ์ฌ๋)๋ก ๋์ฒด
- Annotated tag๋ฅผ pushํ๋ ์ด๋ฒคํธ์์๋
| ํญ๋ชฉ | ์ค๊ณ ๋ฌธ์(2๋จ๊ณ) | ์ค์ ๊ตฌํ | ์ฌ์ |
|---|---|---|---|
| ๋จ์ ํ ์คํธ (PR ๋จ๊ณ) | ํฌํจ | ์ ์ธ | ํ์ฌ ํ ์คํธ ์ฝ๋ ์์ |
dev โ main PR ์ ์ฒด ํ
์คํธ ์ํฌํ๋ก์ฐ |
ํฌํจ | ๋ฏธ๊ตฌํ | ํ์ฌ ํ ์คํธ ์ฝ๋ ์์ |
| main ๋ฐฐํฌ ๋ฒ์ ๊ด๋ฆฌ | ๋ช ์ ์ ๋จ(Semantic Version ํ๊ทธ ์ฌ์ฉ๋ง ๊ธฐ์ ) | Git tag(v*.*.*) push ๊ธฐ๋ฐ, GitHub Release๋ก ์์ฑ |
์ต์ด ๊ตฌํ์ package.json ๋ฒ์ ๋ฐฉ์์ด์์ผ๋, ๋ฒ์ ์ ์ฝ๋ ํ์ผ๋ก ๊ด๋ฆฌํ๋ฉด ๋งค ๋ฐฐํฌ๋ง๋ค ๊ทธ ํ์ผ์ ๊ณ ์น๋ PR์ด ๋ณ๋๋ก ํ์ํจ. Git tag๋ฅผ ๋จ์ผ ์ง์ค ๊ณต๊ธ์์ผ๋ก ์ผ์ผ๋ฉด ๊ทธ ์ ์ฐจ๊ฐ ์์ด์ง๊ณ , "ํ๊ทธ push = ๋ฐฐํฌ ํธ๋ฆฌ๊ฑฐ"๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ถ๋ฆฌ๋๋ค. AI ๋ ํฌ์ ๋์ผํ ๋ฐฉ์์ผ๋ก ํต์ผ |
| main push(merge) ํธ๋ฆฌ๊ฑฐ |
main push(merge) ์ ์ด๋ฏธ์ง ๋น๋ |
release ํ๊ทธ(v*.*.*) push ์ ์ด๋ฏธ์ง ๋น๋ |
์ ๋ฒ์ ๊ด๋ฆฌ ๋ฐฉ์ ๋ณ๊ฒฝ์ ๋ฐ๋ฅธ ํธ๋ฆฌ๊ฑฐ ๋ณ๊ฒฝ |
- Cloud-Design-2nd โ 2๋จ๊ณ CI ํ์ดํ๋ผ์ธ ์ค๊ณ (Trigger, CI Stages, ์คํจ ์ฒ๋ฆฌ ์ ์ฑ ๋ฑ ๊ทผ๊ฑฐ)
- Cloud-Dev-v1-Dockerfile โ Frontend Dockerfile ๊ตฌ์ฑ