ci: Gitea Actions CI/CD 워크플로 추가
This commit is contained in:
@@ -0,0 +1,60 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, dev]
|
||||||
|
pull_request:
|
||||||
|
branches: [main, dev]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
services:
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:11
|
||||||
|
env:
|
||||||
|
MARIADB_ROOT_PASSWORD: ci_root_pw
|
||||||
|
MARIADB_DATABASE: sb_db
|
||||||
|
options: >-
|
||||||
|
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||||
|
--health-interval=10s
|
||||||
|
--health-timeout=5s
|
||||||
|
--health-retries=15
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
options: >-
|
||||||
|
--health-cmd="redis-cli ping"
|
||||||
|
--health-interval=10s
|
||||||
|
--health-timeout=5s
|
||||||
|
--health-retries=10
|
||||||
|
|
||||||
|
env:
|
||||||
|
DB_URL: jdbc:mariadb://mariadb:3306/sb_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Seoul
|
||||||
|
DB_USERNAME: root
|
||||||
|
DB_PASSWORD: ci_root_pw
|
||||||
|
REDIS_HOST: redis
|
||||||
|
REDIS_PORT: '6379'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup JDK 17
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '17'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Build & Test
|
||||||
|
run: |
|
||||||
|
chmod +x ./gradlew
|
||||||
|
./gradlew --no-daemon clean build
|
||||||
|
|
||||||
|
- name: Upload jar
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: app-jar
|
||||||
|
path: build/libs/*.jar
|
||||||
|
retention-days: 7
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
name: Deploy (manual)
|
||||||
|
|
||||||
|
# 배포 대상이 정해지면 아래 단계의 주석을 풀고 시크릿을 등록하세요.
|
||||||
|
# 저장소 Settings > Actions > Secrets 에 등록 필요(예시):
|
||||||
|
# DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY, DEPLOY_PATH
|
||||||
|
# (운영 DB/Redis 접속정보는 서버의 .env 또는 환경변수로 관리)
|
||||||
|
on:
|
||||||
|
workflow_dispatch: {}
|
||||||
|
# push:
|
||||||
|
# tags: ['v*']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup JDK 17
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '17'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Build jar (skip tests)
|
||||||
|
run: |
|
||||||
|
chmod +x ./gradlew
|
||||||
|
./gradlew --no-daemon clean bootJar -x test
|
||||||
|
|
||||||
|
# ===== 배포 예시 (택1) — 사용 시 주석 해제 =====
|
||||||
|
# 1) jar 를 원격 서버로 전송 후 서비스 재시작
|
||||||
|
# - name: Copy jar to server
|
||||||
|
# uses: appleboy/scp-action@v0.1.7
|
||||||
|
# with:
|
||||||
|
# host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
# username: ${{ secrets.DEPLOY_USER }}
|
||||||
|
# key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
# source: "build/libs/*.jar"
|
||||||
|
# target: ${{ secrets.DEPLOY_PATH }}
|
||||||
|
# strip_components: 2
|
||||||
|
# - name: Restart service
|
||||||
|
# uses: appleboy/ssh-action@v1.0.3
|
||||||
|
# with:
|
||||||
|
# host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
# username: ${{ secrets.DEPLOY_USER }}
|
||||||
|
# key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
# script: sudo systemctl restart sb-backend
|
||||||
|
|
||||||
|
# 2) (대안) Docker 이미지 빌드 후 레지스트리 푸시
|
||||||
|
# - name: Build & push image
|
||||||
|
# run: |
|
||||||
|
# docker build -t ${{ secrets.REGISTRY }}/sb-backend:${{ github.sha }} .
|
||||||
|
# docker push ${{ secrets.REGISTRY }}/sb-backend:${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Notice
|
||||||
|
run: echo "jar 빌드 완료. 배포 대상 지정 후 위 단계를 활성화하세요."
|
||||||
Reference in New Issue
Block a user