Skip to content

Merge pull request #47 from junotb/feature/2026-02-12 #5

Merge pull request #47 from junotb/feature/2026-02-12

Merge pull request #47 from junotb/feature/2026-02-12 #5

Workflow file for this run

# main 브랜치 push 시 api, web 이미지 빌드 → Artifact Registry 푸시 → Cloud Run 배포
name: Deploy to Cloud Run
on:
push:
branches: [main]
env:
GCP_REGION: ${{ secrets.GCP_REGION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
AR_REPO: lms
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Create Artifact Registry repository (if not exists)
run: |
if ! gcloud artifacts repositories describe ${{ env.AR_REPO }} --location=${{ env.GCP_REGION }} 2>/dev/null; then
gcloud artifacts repositories create ${{ env.AR_REPO }} \
--repository-format=docker \
--location=${{ env.GCP_REGION }} \
--description="LMS Docker images"
fi
- name: Configure Docker for Artifact Registry
run: gcloud auth configure-docker ${{ env.GCP_REGION }}-docker.pkg.dev --quiet
- name: Build and push API image
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
IMAGE="${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.AR_REPO }}/lms-api"
docker build -f api/Dockerfile -t ${IMAGE}:${SHORT_SHA} -t ${IMAGE}:latest ./api
docker push ${IMAGE}:${SHORT_SHA}
docker push ${IMAGE}:latest
- name: Build and push Web image
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
IMAGE="${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.AR_REPO }}/lms-web"
docker build -f web/Dockerfile -t ${IMAGE}:${SHORT_SHA} -t ${IMAGE}:latest ./web
docker push ${IMAGE}:${SHORT_SHA}
docker push ${IMAGE}:latest
- name: Deploy API to Cloud Run
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
gcloud run deploy lms-api \
--image ${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.AR_REPO }}/lms-api:${SHORT_SHA} \
--region ${{ env.GCP_REGION }} \
--platform managed \
--allow-unauthenticated
- name: Deploy Web to Cloud Run
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
gcloud run deploy lms-web \
--image ${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.AR_REPO }}/lms-web:${SHORT_SHA} \
--region ${{ env.GCP_REGION }} \
--platform managed \
--allow-unauthenticated