1818 REGISTRY : ghcr.io
1919 # github.repository as <account>/<repo>
2020 IMAGE_NAME : ${{ github.repository }}
21+ # docker.io/<account>/<repo>
22+ AUTHOR : urenko
2123
2224
23- jobs :
25+ jobs :
2426 build :
2527
2628 runs-on : ubuntu-latest
@@ -53,20 +55,49 @@ jobs:
5355 # https://github.com/docker/login-action
5456 - name : Log into registry ${{ env.REGISTRY }}
5557 if : github.event_name != 'pull_request'
56- uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
58+ uses : docker/login-action@v3 # v3.0.0
5759 with :
5860 registry : ${{ env.REGISTRY }}
5961 username : ${{ github.actor }}
6062 password : ${{ secrets.GITHUB_TOKEN }}
63+ -
64+ name : Login to Docker Hub
65+ if : github.event_name != 'pull_request'
66+ uses : docker/login-action@v3
67+ with :
68+ username : ${{ secrets.DOCKERHUB_USERNAME }}
69+ password : ${{ secrets.DOCKERHUB_TOKEN }}
6170
6271 # Extract metadata (tags, labels) for Docker
6372 # https://github.com/docker/metadata-action
64- - name : Extract Docker metadata
73+ - name : Extract Docker metadata from ${{ env.REGISTRY }}
6574 id : meta
6675 uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
6776 with :
6877 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6978
79+ - name : Extract Docker metadata from Docker Hub
80+ id : meta_dockerhub
81+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
82+ with :
83+ images : docker.io/${{ secrets.DOCKERHUB_USERNAME || env.AUTHOR }}/${{ github.event.repository.name }}
84+
85+ - name : Extract Docker metadata from ${{ env.REGISTRY }}
86+ id : meta-full
87+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
88+ with :
89+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
90+ flavor : |
91+ suffix=-full,onlatest=true
92+
93+ - name : Extract Docker metadata from Docker Hub
94+ id : meta_dockerhub-full
95+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
96+ with :
97+ images : docker.io/${{ secrets.DOCKERHUB_USERNAME || env.AUTHOR }}/${{ github.event.repository.name }}
98+ flavor : |
99+ suffix=-full,onlatest=true
100+
70101 # Build and push Docker image with Buildx (don't push on PR)
71102 # https://github.com/docker/build-push-action
72103 - name : Build and push Docker image
@@ -75,8 +106,27 @@ jobs:
75106 with :
76107 context : .
77108 push : ${{ github.event_name != 'pull_request' }}
78- tags : ${{ steps.meta.outputs.tags }}
109+ tags : |
110+ ${{ steps.meta.outputs.tags }}
111+ ${{ steps.meta_dockerhub.outputs.tags }}
79112 labels : ${{ steps.meta.outputs.labels }}
113+ build-args : |
114+ BUILDTYPE=minimal
115+ cache-from : type=gha
116+ cache-to : type=gha,mode=max
117+
118+ - name : Build and push Docker image with api_dump.sql
119+ id : build-and-push-full
120+ uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
121+ with :
122+ context : .
123+ push : ${{ github.event_name != 'pull_request' }}
124+ tags : |
125+ ${{ steps.meta-full.outputs.tags }}
126+ ${{ steps.meta_dockerhub-full.outputs.tags }}
127+ labels : ${{ steps.meta.outputs.labels }}
128+ build-args : |
129+ BUILDTYPE=full
80130 cache-from : type=gha
81131 cache-to : type=gha,mode=max
82132
@@ -89,8 +139,22 @@ jobs:
89139 if : ${{ github.event_name != 'pull_request' }}
90140 env :
91141 # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
92- TAGS : ${{ steps.meta.outputs.tags }}
93- DIGEST : ${{ steps.build-and-push.outputs.digest }}
142+ TAGS : |
143+ ${{ steps.meta.outputs.tags }}
144+ DIGEST : |
145+ ${{ steps.build-and-push.outputs.digest }}
146+ # This step uses the identity token to provision an ephemeral certificate
147+ # against the sigstore community Fulcio instance.
148+ run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
149+
150+ - name : Sign the published Docker image for full image
151+ if : ${{ github.event_name != 'pull_request' }}
152+ env :
153+ # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
154+ TAGS : |
155+ ${{ steps.meta-full.outputs.tags }}
156+ DIGEST : |
157+ ${{ steps.build-and-push-full.outputs.digest }}
94158 # This step uses the identity token to provision an ephemeral certificate
95159 # against the sigstore community Fulcio instance.
96160 run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
0 commit comments