1. 문제가 생겼다.
CICD를 생성하는 과정에서 fjogeleit/yaml-update-action@main 를사용하게 되면 deploy될 때 주석이 다 사라지고, 공백이 다 지워져서 파일 관리에 어려움이 있다. 이 문제를 해결하려고 봤더니 이 action은 주석을 제거하는 것으로 알려져 있다고한다. 그래서 고민하는 끝에 pipe라인을 바꾸기로 했다.
2. pipeline을 바꾸자.
조금 돌아가긴 하지만 yq를 이용해서 해결하려고 했다. yq를 통해서 yaml을 바꾸고 commit / push pipeline을 만들어서 사용하기로 한다.
deploy:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: checkout ${{ env.TARGET_REPOSITORY }} repository
uses: actions/checkout@v4
with:
repository: ${{ env.TARGET_REPOSITORY }}
token: ${{ env.GIT_TOKEN }}
ref: 'main'
- uses: mikefarah/yq@master
with:
# cmd: yq eval 'deployment.image.tag = "v-${{ needs.build-and-push.outputs.SHA }}"' helm-values/dev/ggocamping-backend/values.yaml --inplace
cmd: current_commit="v-${{ needs.build-and-push.outputs.SHA }}" yq '.deployment.image.tag = strenv(current_commit)' helm-values/dev/ggocamping-backend/values.yaml --inplace
- name: Commit changes
run: |
git config --local user.email "ggorockee@gmail.com"
git config --local user.name "ggorockee"
git pull origin main
git add .
git commit -m "CI: Update airbnb-server image tag to v-${{ needs.build-and-push.outputs.SHA }}"
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ env.GIT_TOKEN }}
branch: main
repository: ${{ env.TARGET_REPOSITORY }}
3. 문제가 해결되었다.
이렇게 하고 pipe라인을 돌리니 이렇게 주석이 살아있고 태그는 태그대로 변경되는것을 확인할 수 있다.
앞으로는 이 action대신에 yq를 사용해야 할 것 같다.
'devops > minikube' 카테고리의 다른 글
helm template 수정 (0) | 2024.11.27 |
---|---|
k8s와 aws rds 그리고 fiber와 연결 (0) | 2024.11.26 |
15. CICD 구축(마무리) (0) | 2024.11.22 |
14. Docker Image를 이용한 Helm Template 수정 (31) | 2024.11.21 |
13. CI 구축 (26) | 2024.11.21 |