@@ -33,19 +33,48 @@ inputs:
3333 description : ' Docker password'
3434 required : false
3535 default : ' '
36+ tags :
37+ description : " List of tags (supports https://github.com/docker/metadata-action#tags-input)"
38+ required : false
3639outputs :
3740 image :
3841 description : " Docker image name"
3942 value : ${{ inputs.registry }}/${{ inputs.organization }}/${{ inputs.repository }}
4043 tag :
4144 description : " Docker image tag"
42- value : ${{ steps.context.outputs.tag }}
45+ value : ${{ steps.tag.outputs.output }}
46+
4347runs :
4448 using : " composite"
4549 steps :
46- - id : context
47- run : echo "::set-output name=tag::sha-${{ github.sha }}"
48- shell : bash
50+ - name : Docker meta
51+ id : meta
52+ uses : docker/metadata-action@v4
53+ with :
54+ # list of Docker images to use as base name for tags
55+ images : |
56+ ${{ inputs.registry }}/${{ inputs.organization }}/${{ inputs.repository }}
57+ # generate Docker tags based on the following events/attributes
58+ tags : |
59+ type=sha
60+ type=schedule
61+ type=ref,event=branch
62+ type=ref,event=pr
63+ type=semver,pattern={{version}}
64+ type=semver,pattern={{major}}.{{minor}}
65+ type=semver,pattern={{major}}
66+ type=sha,format=long
67+ ${{ inputs.tags }}
68+ labels : |
69+ org.opencontainers.image.source=https://github.com/${{ inputs.organization }}/${{ inputs.repository }}
70+
71+ - uses : edwardgeorge/jq-action@main
72+ id : tag
73+ with :
74+ compact : true
75+ raw-output : true
76+ input : ${{ steps.meta.outputs.json }}
77+ script : ' .tags | map(select(test("sha-\\w{8,}"))) | first | match("sha-\\w{8,}") | .string'
4978
5079 # docker context must be created prior to setting up Docker Buildx
5180 # https://github.com/actions-runner-controller/actions-runner-controller/issues/893
78107 build-args : ${{ inputs.build-args }}
79108 cache-from : type=gha
80109 cache-to : type=gha,mode=max
81- tags : ${{ inputs.registry }}/${{ inputs.organization }}/${{ inputs.repository }}:${{ steps.context .outputs.tag }}
82- labels : org.opencontainers.image.source=https://github.com/ ${{ inputs.organization }}/${{ inputs.repository }}
110+ tags : ${{ steps.meta .outputs.tags }}
111+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments