mirror of
https://github.com/cna-bootcamp/phonebill.git
synced 2025-12-05 23:56:23 +00:00
finalize version1
This commit is contained in:
parent
c5089d59b5
commit
6fa33a7f88
107
.github/workflows/argocd-deploy.yml
vendored
Normal file
107
.github/workflows/argocd-deploy.yml
vendored
Normal file
@ -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가 자동으로 배포합니다."
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user