Merge pull request #63 from SK-Rookies5-Auction/feat/product-detail-r… #69
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: Frontend Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - ci/cd | |
| workflow_dispatch: | |
| env: | |
| AWS_REGION: ap-northeast-2 | |
| FRONTEND_IMAGE_PARAM: /rookies5-macta/dev/infra/FRONTEND_IMAGE | |
| jobs: | |
| deploy: | |
| name: Build & Deploy Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Docker Build & Push | |
| id: build-image | |
| env: | |
| ECR: ${{ secrets.ECR_FRONTEND_URI }} | |
| TAG: ${{ github.sha }} | |
| VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }} | |
| run: | | |
| IMAGE="$ECR:$TAG" | |
| docker build \ | |
| --build-arg VITE_API_BASE_URL="$VITE_API_BASE_URL" \ | |
| -t "$IMAGE" \ | |
| -t "$ECR:latest" \ | |
| . | |
| docker push "$IMAGE" | |
| docker push "$ECR:latest" | |
| echo "image=$IMAGE" >> "$GITHUB_OUTPUT" | |
| - name: Update Frontend Image in SSM | |
| run: | | |
| aws ssm put-parameter \ | |
| --region "${{ env.AWS_REGION }}" \ | |
| --name "${{ env.FRONTEND_IMAGE_PARAM }}" \ | |
| --type SecureString \ | |
| --value "${{ steps.build-image.outputs.image }}" \ | |
| --overwrite | |
| - name: Checkout Infra Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: SK-Rookies5-Auction/infra | |
| token: ${{ secrets.ARGOCD_GIT_TOKEN }} | |
| path: infra-repo | |
| - name: Update k8s | |
| run: | | |
| cd infra-repo | |
| sed -i "s|image: .*|image: ${{ steps.build-image.outputs.image }}|g" k8s/frontend/frontend.yaml | |
| - name: Commit and Push Changes | |
| run: | | |
| cd infra-repo | |
| git config user.name "github-actions" | |
| git config user.email "action@github.com" | |
| git add k8s/frontend/frontend.yaml | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update frontend image to ${{ github.sha }} [skip ci]" | |
| git push origin main | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Update kubeconfig | |
| run: | | |
| aws eks update-kubeconfig \ | |
| --region "${{ env.AWS_REGION }}" \ | |
| --name "${{ secrets.EKS_CLUSTER_NAME }}" | |
| - name: Apply ArgoCD Application | |
| run: | | |
| kubectl apply -f infra-repo/argocd/frontend-application.yml |