From 6fa33a7f8847f45f2e840eaafe326d469c7b1fa1 Mon Sep 17 00:00:00 2001 From: hiondal Date: Tue, 16 Sep 2025 03:20:31 +0900 Subject: [PATCH] finalize version1 --- .github/workflows/argocd-deploy.yml | 107 ++++++++++++++++++++++++++++ kos-mock/data/kos_mock.mv.db | Bin 53248 -> 53248 bytes 2 files changed, 107 insertions(+) create mode 100644 .github/workflows/argocd-deploy.yml diff --git a/.github/workflows/argocd-deploy.yml b/.github/workflows/argocd-deploy.yml new file mode 100644 index 0000000..db14444 --- /dev/null +++ b/.github/workflows/argocd-deploy.yml @@ -0,0 +1,107 @@ +name: ArgoCD Backend Services Deploy + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + +env: + ACR_NAME: acrdigitalgarage01 + ACR_REGISTRY: acrdigitalgarage01.azurecr.io + +jobs: + build: + runs-on: ubuntu-latest + environment: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Set environment variables + run: | + if [ "${{ github.ref }}" = "refs/heads/main" ]; then + echo "ENVIRONMENT=prod" >> $GITHUB_ENV + else + echo "ENVIRONMENT=dev" >> $GITHUB_ENV + fi + echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Run tests + run: ./gradlew test + + - name: Login to Azure Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.ACR_REGISTRY }} + username: ${{ secrets.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} + + - name: Build and push images + run: | + services="api-gateway user-service bill-service product-service kos-mock" + for service in $services; do + echo "Building $service image..." + docker build \ + --build-arg BUILD_LIB_DIR="$service/build/libs" \ + --build-arg ARTIFACTORY_FILE="$service.jar" \ + -f deployment/container/Dockerfile-backend \ + -t ${{ env.ACR_REGISTRY }}/phonebill/$service:${{ env.ENVIRONMENT }}-${{ env.IMAGE_TAG }} . + + echo "Pushing $service image..." + docker push ${{ env.ACR_REGISTRY }}/phonebill/$service:${{ env.ENVIRONMENT }}-${{ env.IMAGE_TAG }} + done + + - name: Update manifest repository + env: + GIT_TOKEN: ${{ secrets.MANIFEST_GITHUB_TOKEN }} + GIT_USERNAME: ${{ secrets.MANIFEST_GITHUB_USERNAME }} + run: | + # 매니페스트 레포지토리 클론 + REPO_URL=$(echo "https://github.com/cna-bootcamp/phonebill-manifest.git" | sed 's|https://||') + git clone https://${GIT_USERNAME}:${GIT_TOKEN}@${REPO_URL} manifest-repo + cd manifest-repo + + # 각 서비스별 이미지 태그 업데이트 (sed 명령 사용) + services="api-gateway user-service bill-service product-service kos-mock" + for service in $services; do + echo "Updating $service image tag..." + sed -i "s|image: ${{ env.ACR_REGISTRY }}/phonebill/$service:.*|image: ${{ env.ACR_REGISTRY }}/phonebill/$service:${{ env.ENVIRONMENT }}-${{ env.IMAGE_TAG }}|g" \ + phonebill/kustomize/base/$service/deployment.yaml + + # 변경 사항 확인 + echo "Updated $service deployment.yaml:" + grep "image: ${{ env.ACR_REGISTRY }}/phonebill/$service" phonebill/kustomize/base/$service/deployment.yaml + done + + # Git 설정 및 푸시 + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git add . + git commit -m "🚀 Update phonebill ${{ env.ENVIRONMENT }} images to ${{ env.ENVIRONMENT }}-${{ env.IMAGE_TAG }}" + git push origin main + + echo "✅ 백엔드 매니페스트 업데이트 완료. ArgoCD가 자동으로 배포합니다." \ No newline at end of file diff --git a/kos-mock/data/kos_mock.mv.db b/kos-mock/data/kos_mock.mv.db index 759f4ab5b202ee390aa904bc112c22e60bd0e184..1f70ecfb4b1425cd022250db1d0b32321db56af3 100644 GIT binary patch delta 62 vcmZozz}&Ead4d{SPHJMFmElAcV@``?Ba delta 54 rcmZozz}&Ead4k$RJwr}&!z5Gl)I>9`jfMUE6B`6431Agoq_6=1)?*Q6