From 0a08075201b46eac3026d02ed2fd4beab0abebe8 Mon Sep 17 00:00:00 2001 From: samzong Date: Thu, 17 Apr 2025 08:55:10 +0800 Subject: [PATCH 1/2] fix: update CI configuration to conditionally push Docker images - Modify the CI configuration to push the Docker image only when it is not a pull request event. - Added conditional judgment for the DockerHub login step to ensure that no push operation is executed during pull request events. Signed-off-by: samzong --- .github/workflows/ci.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2d5b53b..2513e79 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,6 +29,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Log in to DockerHub + if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v3.1.0 with: username: ${{ secrets.DOCKERHUB_TOKEN }} @@ -38,7 +39,7 @@ jobs: uses: docker/build-push-action@v6 with: platforms: linux/amd64,linux/arm64 - push: true + push: ${{ github.event_name != 'pull_request' }} tags: projecthami/hami-webui-fe-oss:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }} build-and-push-backend: @@ -57,6 +58,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Log in to DockerHub + if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v3.1.0 with: username: ${{ secrets.DOCKERHUB_TOKEN }} @@ -67,5 +69,5 @@ jobs: with: context: ./server platforms: linux/amd64,linux/arm64 - push: true + push: ${{ github.event_name != 'pull_request' }} tags: projecthami/hami-webui-be-oss:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }} From afd4d7c7761c0c36d90e2d6375b6ab9598e383c6 Mon Sep 17 00:00:00 2001 From: samzong Date: Thu, 17 Apr 2025 09:03:30 +0800 Subject: [PATCH 2/2] fix: update ci configuration for docker image tagging Signed-off-by: samzong --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2513e79..cbfdcbc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,7 +40,7 @@ jobs: with: platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} - tags: projecthami/hami-webui-fe-oss:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }} + tags: projecthami/hami-webui-fe-oss:${{ steps.branch-names.outputs.tag || steps.branch-names.outputs.current_branch == 'main' && 'main' || format('pr-{0}', github.run_number) }} build-and-push-backend: name: Build and Push Backend Image @@ -70,4 +70,4 @@ jobs: context: ./server platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} - tags: projecthami/hami-webui-be-oss:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }} + tags: projecthami/hami-webui-be-oss:${{ steps.branch-names.outputs.tag || steps.branch-names.outputs.current_branch == 'main' && 'main' || format('pr-{0}', github.run_number) }}