[SRLT-122] prod workflow에서 arm64를 지원하도록 수정한다 #141
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: Deployment Workflow | |
| on: | |
| push: | |
| branches: [ "develop" ] | |
| pull_request: | |
| branches: [ "develop" ] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| env: | |
| SPRING_PROFILES_ACTIVE: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.PAT }} | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle Wrapper | |
| run: ./gradlew clean build --info --stacktrace --no-daemon | |
| - name: Docker login | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set image tag | |
| id: vars | |
| run: echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_ENV | |
| # Multi-architecture 빌드 및 푸시 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: deploy/Dockerfile | |
| platforms: linux/amd64,linux/arm64 # 두 아키텍처 모두 빌드 | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/startuplight-be:${{ env.IMAGE_TAG }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Checkout manifest repository | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: 'StartUpLight/STARLIGHT_MANIFEST' | |
| token: ${{ secrets.PAT }} | |
| path: 'manifest' | |
| - name: Update deployment.yml | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
| run: | | |
| sed -i "s|image:.*|image: ${DOCKERHUB_USERNAME}/startuplight-be:${IMAGE_TAG}|g" manifest/staging/deployment.yml | |
| # 변경사항 확인 | |
| echo "Updated deployment.yml:" | |
| cat manifest/staging/deployment.yml | |
| - name: Commit and push changes | |
| env: | |
| IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
| run: | | |
| cd manifest | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "SeongHo5356" | |
| git add staging/deployment.yml | |
| git commit -m "Update image tag to $IMAGE_TAG" || exit 0 | |
| git push | |
| - name: Checkout manifest repository (oracle) | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: 'StartUpLight/STARLIGHT_MANIFEST_ORACLE' | |
| token: ${{ secrets.PAT }} | |
| path: 'manifest-oracle' | |
| - name: Update deployment.yml (oracle) | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
| run: | | |
| sed -i "s|image:.*|image: ${DOCKERHUB_USERNAME}/startuplight-be:${IMAGE_TAG}|g" manifest-oracle/staging/deployment.yml | |
| echo "Updated deployment.yml (oracle):" | |
| cat manifest-oracle/staging/deployment.yml | |
| - name: Commit and push changes (oracle) | |
| env: | |
| IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
| run: | | |
| cd manifest-oracle | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "SeongHo5356" | |
| git add staging/deployment.yml | |
| git commit -m "Update image tag to $IMAGE_TAG" || exit 0 | |
| git push |