Skip to content

chore: .coderabbit.yaml 설정 추가 #20

chore: .coderabbit.yaml 설정 추가

chore: .coderabbit.yaml 설정 추가 #20

Workflow file for this run

name: Build and Deploy to EC2
on:
push:
branches: [ "main" ]
env:
GCP_PROJECT_ID: "lessonplatform-495307"
GCP_REGION: "asia-northeast3"
ARTIFACT_REGISTRY_REPO: "notification-server-repo" # GCP에 만들 이미지 저장소 이름
IMAGE_NAME: "spring-app"
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # GCP Workload Identity와 통신하기 위한 OIDC 토큰 발행 권한
steps:
- name: Code Checkout
uses: actions/checkout@v4
# 2. JDK 설정 및 자바 스프링 빌드
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Build Spring Boot Application
run: ./gradlew build -x test
# 3. GCP 인증 (Workload Identity)
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
# 4. 도커 이미지 빌드 및 GCP Artifact Registry로 Push
- name: Configure Docker for GCP
run: gcloud auth configure-docker asia-northeast3-docker.pkg.dev
- name: Build and Push Docker Image
run: |
docker build -t asia-northeast3-docker.pkg.dev/$GCP_PROJECT_ID/$ARTIFACT_REGISTRY_REPO/$IMAGE_NAME:latest .
docker push asia-northeast3-docker.pkg.dev/$GCP_PROJECT_ID/$ARTIFACT_REGISTRY_REPO/$IMAGE_NAME:latest
# 5. CP VM의 컨테이너 이미지 업데이트 및 재시작 명령
- name: Deploy to GCP Compute Engine
run: |
gcloud compute instances reset spring --zone=asia-northeast3-a