-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.91 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Build and Push Docker Image to ACR
on:
push:
branches:
- main
workflow_dispatch: # 수동 실행을 위한 트리거
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# ACR에 로그인 (CLI 환경은 사내에서 되지 않음)
- name: Log in to Azure
uses: azure/docker-login@v1
with:
login-server: ${{secrets.AZURE_URL}}
username: ${{secrets.AZURE_ID}}
password: ${{secrets.AZURE_PASSWORD}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 현재 시간 기준으로 태그 생성
- name: Generate tag based on current time
run: echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Build and push to ACR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ secrets.AZURE_URL }}/jinni:${{ env.IMAGE_TAG }}
# Kustomize 명령 가져오기
- name: Update kustomization.yaml with new image tag
uses: actions/checkout@v4
with:
repository: JourneyJinni/gitops
ref: main
token: ${{ secrets.GIT_TOKEN }}
path: gitops
# 업데이트된 Kustomize 설정 적용
- name: Apply Kustomize resoureces
run: |
pwd
cd gitops/backend/base
kustomize edit set image ${{ secrets.AZURE_URL }}/jinni:${{ env.IMAGE_TAG }}
cat kustomization.yaml
# commit & push 설정
- name: Commit Manifest
run: |
cd gitops/backend/base
git config --global user.name 'git-actions'
git config --global user.email '[email protected]'
git add kustomization.yaml
git commit -m 'Update image tag from Github Action'
cat kustomization.yaml
git push origin HEAD