fix: 큰따옴표 추가 #16
This file contains 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: AWS ECR push & deploy k8s | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
# Github에 저장된 코드를 CI 서버로 내려받아 뒷 step에서 사용할 수 있도록 하는 과정 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Github Secret과 local env 에 저장된 값 불러오기 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} # secret에 저장되어 있는 값 불러오기 | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push the image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: demo-frontend | |
IMAGE_TAG: ${{ github.run_number }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "Pushing image to ECR..." | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
# kustomize 명령을 가져온다. | |
- name: Setup Kustomize | |
uses: imranismail/setup-kustomize@v1 | |
- name: Checkout kustomize repository | |
uses: actions/checkout@v2 | |
with: | |
# kubernetes 설정정보 저장소 | |
repository: TUK-MoreView/k8s-manifest-repo # k8s yaml 파일이 있는 repo | |
ref: main # branch 이름 | |
# 다른 저장소에 push 하려면 Personal Access Token이 필요. | |
token: ${{ secrets.ACTION_TOKEN }} | |
path: k8s-manifest-repo # 최상위 경로로 repository와 동일하게 설정 | |
- name: Update Kubernetes resources | |
run: | | |
echo ${{ steps.login-ecr.outputs.registry }} | |
echo ${{ steps.image-info.outputs.ecr_repository }} | |
echo ${{ steps.image-info.outputs.image_tag }} | |
cd k8s-manifest-repo/overlays/dev/ | |
kustomize edit set image ${{ steps.login-ecr.outputs.registry}}/${{ steps.image-info.outputs.ecr_repository }}=${{ steps.login-ecr.outputs.registry}}/${{ steps.image-info.outputs.ecr_repository }}:${{ steps.image-info.outputs.image_tag }} | |
cat kustomization.yaml | |
# 수정된 파일 commit & push | |
- name: Commit files | |
env: | |
ECR_REPOSITORY: demo-frontend | |
IMAGE_TAG: ${{ github.run_number }} | |
run: | | |
cd k8s-manifest-repo | |
git config --global user.email "[email protected]" | |
git config --global user.name "why-only-english" | |
git commit -am "Update image $ECR_REPOSITORY tag $IMAGE_TAG" | |
git push -u origin main |