1- # https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
2-
31name : Docker Package
42
53on :
1412 - master
1513
1614env :
17- # Use docker.io for Docker Hub if empty
1815 REGISTRY : ghcr.io
19- # github.repository as <account>/<repo>
2016 IMAGE_NAME : ${{ github.repository }}
2117 RELEASE_VERSION : ${{ github.ref_name }}
2218
2319jobs :
2420 package :
2521 runs-on : ubuntu-latest
26-
27- # Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
2822 permissions :
2923 contents : read
3024 packages : write
3125 attestations : write
3226 id-token : write
33-
3427 steps :
35- - name : Checkout repository
36- uses : actions/checkout@v4
28+ - uses : ./.github/actions/setup-go
3729
38- # https://github.com/docker/login-action
3930 - name : Log in to the Container registry ${{ env.REGISTRY }}
4031 if : github.event_name != 'pull_request'
4132 uses : docker/login-action@v3
4233 with :
4334 registry : ${{ env.REGISTRY }}
4435 username : ${{ github.actor }}
45- # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication
4636 password : ${{ secrets.GITHUB_TOKEN }}
4737
48- # https://github.com/docker/metadata-action
4938 - name : Extract metadata (tags, labels) for Docker
5039 id : meta
5140 uses : docker/metadata-action@v5
5241 with :
5342 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54- # generate Docker tags based on the following events/attributes
5543 tags : |
56- # set latest tag for master branch
5744 type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
5845 type=ref,event=tag
5946 type=ref,event=pr
6047 type=sha
6148
62- # https://github.com/docker/build-push-action
63- # For pull request, only ensures that the docker build succeeds, does not push the image.
64- # See: https://github.com/docker/build-push-action/issues/751
6549 - name : Build and push Docker image
6650 id : push
6751 uses : docker/build-push-action@v6
@@ -72,12 +56,10 @@ jobs:
7256 tags : ${{ steps.meta.outputs.tags }}
7357 labels : ${{ steps.meta.outputs.labels }}
7458
75- # https://github.com/actions/attest-build-provenance
7659 - name : Generate artifact attestation
7760 if : github.event_name != 'pull_request'
7861 uses : actions/attest-build-provenance@v2
7962 with :
80- subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
63+ subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8164 subject-digest : ${{ steps.push.outputs.digest }}
82- # https://github.com/actions/attest-build-provenance/issues/71#issuecomment-2108140285
8365 push-to-registry : false
0 commit comments