Skip to content

chore: Add logging in user listener in quiz service #66

chore: Add logging in user listener in quiz service

chore: Add logging in user listener in quiz service #66

name: Quiz Image Build
env:
SERVICE_NAME: quiz-service
BUILD_ID: ${{ github.sha }}-${{ github.run_id }}
HELM_VALUE: quiz-service-chart/values-dev.yaml
HELM_BRANCH: dev
on:
push:
branches:
- 'develop'
paths:
- 'quiz-service/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Google Cloud Auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Configure Docker Authentication
run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev --quiet
- name: Build, tag, and push docker image to Google Artifact Registry
env:
IMAGE_TAG: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ env.BUILD_ID }}
run: |
docker build -f ./quiz-service/quiz-application/app-api/Dockerfile -t $IMAGE_TAG .
docker push $IMAGE_TAG
- name: Checkout Helm Repository
uses: actions/checkout@v4
with:
repository: quizy-web/quizy-helm-charts
path: helm-chart
ref: ${{ env.HELM_BRANCH }}
ssh-key: ${{ secrets.HELM_REPO_SSH_KEY }}
- name: Change Image tag of the Helm Chart
uses: mikefarah/[email protected]
with:
cmd: yq -i '.image.tag = "${{ env.BUILD_ID }}"' helm-chart/${{ env.HELM_VALUE }}
- name: Commit and Push Helm Chart Changes
run: |
cd helm-chart
git config --local user.email "[email protected]"
git config --local user.name "githubaction"
git add ${{ env.HELM_VALUE }}
git commit -m "Update ${SERVICE_NAME} image tag to ${{ env.BUILD_ID }}" || echo "No changes to commit"
attempts=0
max_attempts=3
while [ $attempts -lt $max_attempts ]; do
if git push --force origin ${{ env.HELM_BRANCH }}; then
echo "Push successful!"
break
else
echo "Push failed due to remote ref lock. Attempting rebase with remote branch."
# 원격 브랜치 최신 상태 반영
git pull --rebase origin ${{ env.HELM_BRANCH }}
attempts=$((attempts+1))
if [ $attempts -eq $max_attempts ]; then
echo "Push failed after $max_attempts attempts"
exit 1
fi
echo "Retrying push..."
fi
done