user 삭제 시 auth 호출로직 추가 #19
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
| # 워크플로우의 이름 | |
| name: Deploy to GKE | |
| # 언제 이 워크플로우를 실행할지 정의 | |
| on: | |
| push: | |
| branches: | |
| - main # 'main' 브랜치에 코드가 푸시될 때마다 실행 | |
| # 워크플로우 전체에서 사용할 환경 변수 설정 | |
| env: | |
| PROJECT_ID: gearfirst | |
| GKE_CLUSTER: gearfirst-cluster | |
| GKE_REGION: asia-northeast1 | |
| ARTIFACT_REGISTRY: asia-northeast1-docker.pkg.dev | |
| REPO_NAME: gearfirst-docker-repo | |
| SERVICE_NAME: user-service | |
| DEPLOYMENT_NAME: user-service-deployment | |
| # 실제 수행할 작업(Job) 정의 | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest # 이 작업은 ubuntu 환경에서 실행됩니다. | |
| steps: | |
| # 1. GitHub 저장소의 코드를 작업 환경으로 가져옵니다. | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # 2. GitHub Secrets에 저장된 GCP 서비스 계정 키를 사용하여 인증합니다. | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v1 | |
| with: | |
| credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
| # 3. gcloud CLI를 설정합니다. | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v1 | |
| with: | |
| project_id: ${{ env.PROJECT_ID }} | |
| # --- 문제 1 해결: gke-gcloud-auth-plugin 설치 단계 추가 --- | |
| - name: Install gke-gcloud-auth-plugin | |
| run: gcloud components install gke-gcloud-auth-plugin | |
| # 4. Docker 이미지를 빌드하고 Artifact Registry에 푸시합니다. | |
| # 이미지 태그는 고유한 값인 Git 커밋 해시(github.sha)를 사용합니다. | |
| - name: Build and Push Docker Image | |
| run: | | |
| gcloud auth configure-docker ${{ env.ARTIFACT_REGISTRY }} | |
| docker build --platform linux/amd64 -t ${{ env.ARTIFACT_REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }} . | |
| docker push ${{ env.ARTIFACT_REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }} | |
| # 5. GKE 클러스터에 접속하여 배포된 이미지의 버전을 업데이트합니다. | |
| - name: Deploy to GKE | |
| run: | | |
| gcloud container clusters get-credentials ${{ env.GKE_CLUSTER }} --region ${{ env.GKE_REGION }} | |
| kubectl set image deployment/${{ env.DEPLOYMENT_NAME }} ${{ env.SERVICE_NAME }}-container=${{ env.ARTIFACT_REGISTRY }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }} |