@@ -2,33 +2,46 @@ name: "Build Docker Image"
22description : " Builds a Docker image"
33inputs :
44 context :
5- description : " Path to the Docker build context."
6- required : true
5+ description : " Path to the Docker build context"
6+ required : false
7+ default : " ."
78 repository :
8- description : " Repository name for the Docker image (defaults to current GitHub repository). "
9+ description : " Repository name for the Docker image (defaults to current GitHub repository)"
910 required : false
1011 default : ${{ github.repository }}
1112 domain :
12- description : " The image's domain. "
13+ description : " The image's domain"
1314 required : true
1415 registry :
15- description : Azure Registry to authenticate against.
16+ description : " Azure Registry to authenticate against"
1617 required : true
18+ tag :
19+ description : " Tag for the Docker image"
20+ required : false
21+ default : ${{ github.ref_name }}
22+ outputs :
23+ docker_image_name :
24+ description : " The name of the Docker image"
25+ value : ${{ steps.set_image_name_and_tag.outputs.docker_image_name }}
26+ docker_image_tag :
27+ description : " The version of the Docker image"
28+ value : ${{ steps.set_image_name_and_tag.outputs.docker_image_tag }}
1729runs :
1830 using : " composite"
1931 steps :
2032 - name : Checkout code
2133 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2234
23- - name : Setup docker image name
35+ - name : Setup Docker image name and tag
36+ id : set_image_name_and_tag
2437 run : |
25- IMAGE_TAG ="${{ github.ref_name }}"
38+ DOCKER_IMAGE_TAG ="${{ inputs.tag }}"
2639 REPO_NAME=$(basename "${{ inputs.repository }}")
27- DOCKER_IMAGE_NAME="${{ inputs.registry }}/${{ inputs.domain }}/${REPO_NAME}:${IMAGE_TAG}"
28- echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME,,}" >> $GITHUB_ENV
40+ DOCKER_IMAGE_NAME="${{ inputs.registry }}/${{ inputs.domain }}/${REPO_NAME}"
2941 echo "docker_image_name=$DOCKER_IMAGE_NAME" >> $GITHUB_OUTPUT
42+ echo "docker_image_tag=$DOCKER_IMAGE_TAG" >> $GITHUB_OUTPUT
3043 shell : bash
3144
3245 - name : Build the docker image
33- run : docker build ${{ inputs.context }} -t ${{ env.DOCKER_IMAGE_NAME }}
46+ run : docker build ${{ inputs.context }} -t ${{ steps.set_image_name_and_tag.outputs.docker_image_name }}:${{ steps.set_image_name_and_tag.outputs.docker_image_tag }}
3447 shell : bash
0 commit comments