@@ -3,9 +3,7 @@ name: Build and Push Docker Image
33on :
44 push :
55 branches :
6- - main
7- - master
8- - dev
6+ - sni-support
97 paths :
108 - ' Dockerfile'
119 - ' go.mod'
1917 - ' models/**'
2018 - ' services/**'
2119 - ' ui/**'
22-
23- tags :
24- - ' v*'
2520 workflow_dispatch :
2621
2722env :
@@ -53,56 +48,22 @@ jobs:
5348 username : ${{ secrets.DOCKERHUB_USERNAME }}
5449 password : ${{ secrets.DOCKERHUB_TOKEN }}
5550
56- # Get current date for image tags
57- - name : Get current date
58- id : date
59- run : echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
60-
6151 # Prepare tags based on branch and version
6252 - name : Prepare Docker tags
6353 id : docker_tags
6454 run : |
6555 TAGS=""
66-
67- # Add branch-specific tags
68- if [[ "${{ github.ref_name }}" == "main" || "${{ github.ref_name }}" == "master" ]]; then
69- # For main/master branch, add latest tag
70- TAGS="$TAGS ${{ env.DOCKERHUB_IMAGE_NAME }}:latest"
71- elif [[ "${{ github.ref_name }}" == "dev" ]]; then
72- # For dev branch
73- TAGS="$TAGS ${{ env.DOCKERHUB_IMAGE_NAME }}:dev"
74- elif [[ "${{ github.ref_type }}" == "branch" ]]; then
75- # For other branches
76- TAGS="$TAGS ${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.ref_name }}"
77- fi
78-
79- # Add sha tag for all branches
80- if [[ "${{ github.ref_type }}" == "branch" ]]; then
81- TAGS="$TAGS,${{ env.DOCKERHUB_IMAGE_NAME }}:sha-${GITHUB_SHA::7}"
82- fi
83-
84- # Add version tag for tagged releases
85- if [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref }}" == refs/tags/v* ]]; then
86- VERSION="${{ github.ref_name }}"
87-
88- # Add full version tag
89- TAGS="$TAGS,${{ env.DOCKERHUB_IMAGE_NAME }}:$VERSION"
56+ if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "sni-support" ]]; then
57+ TAGS="${{ env.DOCKERHUB_IMAGE_NAME }}:sni-support"
9058 fi
91-
92- # Add date tag for all builds
93- TAGS="$TAGS,${{ env.DOCKERHUB_IMAGE_NAME }}:${{ steps.date.outputs.date }}"
94-
95- # Remove leading space or comma if present
96- TAGS=$(echo "$TAGS" | sed 's/^[ ,]*//')
97-
9859 echo "tags=$TAGS" >> $GITHUB_OUTPUT
9960 echo "Docker tags: $TAGS"
10061
10162 - name : Build and push
10263 uses : docker/build-push-action@v5
10364 with :
10465 context : .
105- push : true
66+ push : ${{ steps.docker_tags.outputs.tags != '' }} # IMPORTANT: Only push if tags were generated
10667 platforms : linux/amd64,linux/arm64
10768 tags : ${{ steps.docker_tags.outputs.tags }}
10869 cache-from : type=gha
0 commit comments