Fix: db environment 수정 #18
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: Docker Deploy (Dev/Stg) | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - stg | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get short commit SHA and branch | |
| id: vars | |
| run: | | |
| echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/bannote-studyroom-service:${{ steps.vars.outputs.BRANCH }}-${{ steps.vars.outputs.SHORT_SHA }} | |
| cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/bannote-studyroom-service:buildcache | |
| cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/bannote-studyroom-service:buildcache,mode=max | |
| - name: Image deployed | |
| run: | | |
| echo "🚀 Docker image pushed to Docker Hub!" | |
| echo "📦 Image: ${{ secrets.DOCKERHUB_USERNAME }}/bannote-studyroom-service:${{ steps.vars.outputs.BRANCH }}-${{ steps.vars.outputs.SHORT_SHA }}" | |
| - name: Checkout infra repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: gsc-lab/cs25-1-bannote-infra | |
| token: ${{ secrets.GH_PAT }} | |
| path: infra | |
| - name: Update Helm values.yaml | |
| run: | | |
| cd infra | |
| BRANCH="${{ steps.vars.outputs.BRANCH }}" | |
| VALUES_FILE="helm/service/studyroom-service/values/${BRANCH}/values.yaml" | |
| NEW_TAG="${BRANCH}-${{ steps.vars.outputs.SHORT_SHA }}" | |
| # Install yq for YAML manipulation | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| # Update tag in values.yaml | |
| yq eval ".image.tag = \"$NEW_TAG\"" -i "$VALUES_FILE" | |
| echo "✅ Updated tag to: $NEW_TAG" | |
| - name: Commit and push changes | |
| run: | | |
| cd infra | |
| BRANCH="${{ steps.vars.outputs.BRANCH }}" | |
| git config user.name "github-actions[studyroom-service]" | |
| git config user.email "github-actions[studyroom-service]@users.noreply.github.com" | |
| git add helm/service/studyroom-service/values/${BRANCH}/values.yaml | |
| git commit -m "chore: update studyroom-service ${BRANCH} image tag to ${BRANCH}-${{ steps.vars.outputs.SHORT_SHA }}" | |
| git push | |
| echo "🚀 Infra repository updated successfully!" |