Merge pull request #43 from junotb/feature/2026-02-12 #1
This file contains hidden or 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
| # main 브랜치 push 시 api, web 이미지 빌드 → ghcr.io 푸시 → Cloud Run 배포 | |
| name: Deploy to Cloud Run | |
| on: | |
| push: | |
| branches: [main] | |
| env: | |
| GCP_REGION: ${{ secrets.GCP_REGION }} | |
| GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| GHCR_IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }} | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push API image | |
| run: | | |
| SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
| docker build -f api/Dockerfile -t ${{ env.GHCR_IMAGE_PREFIX }}/lms-api:$SHORT_SHA -t ${{ env.GHCR_IMAGE_PREFIX }}/lms-api:latest ./api | |
| docker push ${{ env.GHCR_IMAGE_PREFIX }}/lms-api:$SHORT_SHA | |
| docker push ${{ env.GHCR_IMAGE_PREFIX }}/lms-api:latest | |
| - name: Build and push Web image | |
| run: | | |
| SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
| docker build -f web/Dockerfile -t ${{ env.GHCR_IMAGE_PREFIX }}/lms-web:$SHORT_SHA -t ${{ env.GHCR_IMAGE_PREFIX }}/lms-web:latest ./web | |
| docker push ${{ env.GHCR_IMAGE_PREFIX }}/lms-web:$SHORT_SHA | |
| docker push ${{ env.GHCR_IMAGE_PREFIX }}/lms-web:latest | |
| - 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: Deploy API to Cloud Run | |
| run: | | |
| SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7) | |
| gcloud run deploy lms-api \ | |
| --image ${{ env.GHCR_IMAGE_PREFIX }}/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.GHCR_IMAGE_PREFIX }}/lms-web:${SHORT_SHA} \ | |
| --region ${{ env.GCP_REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated |