From 6ba747b9ec60b30971f8902baba156f36661095e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:35:41 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[feat]=20docker=20hub=20push=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..cc78a17 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,37 @@ +name: CI/CD - Docker Image Build and Push + +# 1. 워크플로우 실행 조건: main 브랜치에 push 이벤트가 발생했을 때 +on: + push: + branches: [ "develop" ] + +jobs: + build-and-push: + runs-on: ubuntu-latest # 작업이 실행될 가상 머신 환경 + + steps: + # 2. 코드 체크아웃: GitHub 저장소의 코드를 가상 머신으로 가져옴 + - name: Checkout repository + uses: actions/checkout@v4 + + # 3. Docker Hub 로그인: 1단계에서 저장한 Secrets를 사용해 Docker Hub에 로그인 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # 4. 이미지 태그 동적 생성: 날짜 기반으로 이미지 태그를 만듦 (예: decs:251002) + - name: Generate image tag + id: generate_tag + run: echo "TAG_NAME=decs:$(date +'%y%m%d')" >> $GITHUB_OUTPUT + + # 5. Docker 이미지 빌드 및 푸시 + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . # Dockerfile이 있는 경로 (저장소 최상위) + push: true # 빌드 후 Docker Hub로 푸시 + tags: | + dguailab/decs:${{ steps.generate_tag.outputs.TAG_NAME }} + dguailab/decs:latest From e48bd39136365b45cf5152e1d5d0a633987957cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:38:28 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[chore]=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20tag.yml=EC=9D=84=20=EC=82=AD=EC=A0=9C=ED=95=98?= =?UTF-8?q?=EA=B3=A0=20docker=EA=B4=80=EB=A0=A8=20yml=EC=97=90=20=EB=B3=91?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tag.yml | 40 --------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml deleted file mode 100644 index 0168b1f..0000000 --- a/.github/workflows/tag.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Create Tag from Merged Branch - -# 워크플로우 실행 조건 설정 -on: - pull_request: - types: [closed] - branches: - - 'main' - -jobs: - tag-from-branch: - # PR이 'merged' 상태일 때만 job을 실행 (그냥 닫힌 경우는 제외) - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - # 1. 저장소 코드를 체크아웃 - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # 2. 병합된 브랜치 이름으로 태그 생성 및 푸시 - - name: Create and Push Tag - run: | - # 병합된 브랜치(head_ref)의 이름을 변수로 저장 - BRANCH_NAME=${{ github.event.pull_request.head.ref }} - - echo "Merged branch name is: $BRANCH_NAME" - - # Git 사용자 설정 (Action이 커밋/태그를 생성하기 위해 필요) - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - # 브랜치 이름으로 Annotated Tag 생성 - git tag -a "$BRANCH_NAME" -m "Tag automatically created from merged branch: $BRANCH_NAME" - - # 생성된 태그를 원격 저장소로 푸시 - git push origin "$BRANCH_NAME" - - echo "Successfully created and pushed tag: $BRANCH_NAME" From 9dbd5b08e43388c4edf433d236d22ba1612bcde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:41:33 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[chore]=20=EC=8B=A4=ED=96=89=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EB=B0=8F=20=ED=83=9C=EA=B7=B8=20=EC=B6=94=EC=B6=9C?= =?UTF-8?q?=20=EB=B0=A9=EB=B2=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 40 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cc78a17..228a63b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,37 +1,47 @@ -name: CI/CD - Docker Image Build and Push +name: CI/CD - Docker Image from DECS Branch -# 1. 워크플로우 실행 조건: main 브랜치에 push 이벤트가 발생했을 때 +# 1. 실행 조건 변경: 'develop' 브랜치를 대상으로 하는 PR이 닫혔을 때 on: - push: - branches: [ "develop" ] + pull_request: + types: [closed] + branches: [ "develop" ] # 타겟 브랜치 jobs: build-and-push: - runs-on: ubuntu-latest # 작업이 실행될 가상 머신 환경 + # 2. 상세 실행 조건: PR이 '병합'되었고, 소스 브랜치가 'decs'로 시작할 때만 실행 + if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'decs') + runs-on: ubuntu-latest steps: - # 2. 코드 체크아웃: GitHub 저장소의 코드를 가상 머신으로 가져옴 - name: Checkout repository uses: actions/checkout@v4 - # 3. Docker Hub 로그인: 1단계에서 저장한 Secrets를 사용해 Docker Hub에 로그인 - name: Log in to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCK_USERNAME }} + password: ${{ secrets.DOCK_TOKEN }} - # 4. 이미지 태그 동적 생성: 날짜 기반으로 이미지 태그를 만듦 (예: decs:251002) - - name: Generate image tag + # 3. 태그 추출 방식 변경: 'decs' 접두사 제거 + - name: Generate tag from branch name id: generate_tag - run: echo "TAG_NAME=decs:$(date +'%y%m%d')" >> $GITHUB_OUTPUT + run: | + # 병합된 브랜치 이름을 가져옴 (예: 'decs251002') + BRANCH_NAME=${{ github.event.pull_request.head.ref }} + + # 'decs' 접두사를 제거하여 버전만 추출 (예: '251002') + TAG_VERSION=${BRANCH_NAME#decs} + + echo "Extracted tag version: $TAG_VERSION" + + # 다음 단계에서 사용할 수 있도록 태그 이름을 GITHUB_OUTPUT에 저장 + echo "TAG_NAME=$TAG_VERSION" >> $GITHUB_OUTPUT - # 5. Docker 이미지 빌드 및 푸시 - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: . # Dockerfile이 있는 경로 (저장소 최상위) - push: true # 빌드 후 Docker Hub로 푸시 + context: . + push: true tags: | dguailab/decs:${{ steps.generate_tag.outputs.TAG_NAME }} dguailab/decs:latest From 6b7d073e20ed2f1e0aae6aa95e5ddd5e0d8661ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:46:17 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[fix]=20=EB=93=A4=EC=97=AC=EC=93=B0?= =?UTF-8?q?=EA=B8=B0=20=EB=B0=8F=20=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 228a63b..1c1ba3a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,14 +1,12 @@ name: CI/CD - Docker Image from DECS Branch -# 1. 실행 조건 변경: 'develop' 브랜치를 대상으로 하는 PR이 닫혔을 때 on: pull_request: types: [closed] - branches: [ "develop" ] # 타겟 브랜치 + branches: [ "develop" ] jobs: build-and-push: - # 2. 상세 실행 조건: PR이 '병합'되었고, 소스 브랜치가 'decs'로 시작할 때만 실행 if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'decs') runs-on: ubuntu-latest @@ -19,22 +17,15 @@ jobs: - name: Log in to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCK_USERNAME }} - password: ${{ secrets.DOCK_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} - # 3. 태그 추출 방식 변경: 'decs' 접두사 제거 - name: Generate tag from branch name id: generate_tag run: | - # 병합된 브랜치 이름을 가져옴 (예: 'decs251002') BRANCH_NAME=${{ github.event.pull_request.head.ref }} - - # 'decs' 접두사를 제거하여 버전만 추출 (예: '251002') TAG_VERSION=${BRANCH_NAME#decs} - echo "Extracted tag version: $TAG_VERSION" - - # 다음 단계에서 사용할 수 있도록 태그 이름을 GITHUB_OUTPUT에 저장 echo "TAG_NAME=$TAG_VERSION" >> $GITHUB_OUTPUT - name: Build and push Docker image From 7f3857e95e80d4c358e713eb6ab2eb653e7992bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?toni=20=28=EC=9D=B4=EC=86=8C=EC=9D=80=29?= <144209738+saokiritoni@users.noreply.github.com> Date: Thu, 2 Oct 2025 13:48:48 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[fix]=20startsWith=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 1c1ba3a..ff10d01 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,7 @@ on: jobs: build-and-push: - if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'decs') + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: