Skip to content

Commit 65eeb6f

Browse files
committed
github ci updated
1 parent 661804f commit 65eeb6f

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

.github/workflows/docker-publish.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ name: Docker
77

88
on:
99
push:
10-
branches: [ main ]
10+
branches: [ "main" ]
1111
# Publish semver tags as releases.
1212
tags: [ 'v*.*.*' ]
1313
pull_request:
14-
branches: [ main ]
14+
branches: [ "main" ]
1515

1616
env:
1717
# Use docker.io for Docker Hub if empty
@@ -27,16 +27,33 @@ jobs:
2727
permissions:
2828
contents: read
2929
packages: write
30+
# This is used to complete the identity challenge
31+
# with sigstore/fulcio when running outside of PRs.
32+
id-token: write
3033

3134
steps:
3235
- name: Checkout repository
33-
uses: actions/checkout@v2
36+
uses: actions/checkout@v3
37+
38+
# Install the cosign tool except on PR
39+
# https://github.com/sigstore/cosign-installer
40+
- name: Install cosign
41+
if: github.event_name != 'pull_request'
42+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
43+
with:
44+
cosign-release: 'v2.1.1'
45+
46+
# Set up BuildKit Docker container builder to be able to build
47+
# multi-platform images and export cache
48+
# https://github.com/docker/setup-buildx-action
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
3451

3552
# Login against a Docker registry except on PR
3653
# https://github.com/docker/login-action
3754
- name: Log into registry ${{ env.REGISTRY }}
3855
if: github.event_name != 'pull_request'
39-
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
56+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
4057
with:
4158
registry: ${{ env.REGISTRY }}
4259
username: ${{ github.actor }}
@@ -46,16 +63,34 @@ jobs:
4663
# https://github.com/docker/metadata-action
4764
- name: Extract Docker metadata
4865
id: meta
49-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
66+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
5067
with:
5168
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5269

5370
# Build and push Docker image with Buildx (don't push on PR)
5471
# https://github.com/docker/build-push-action
5572
- name: Build and push Docker image
56-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
73+
id: build-and-push
74+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
5775
with:
5876
context: .
5977
push: ${{ github.event_name != 'pull_request' }}
6078
tags: ${{ steps.meta.outputs.tags }}
6179
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
83+
# Sign the resulting Docker image digest except on PRs.
84+
# This will only write to the public Rekor transparency log when the Docker
85+
# repository is public to avoid leaking data. If you would like to publish
86+
# transparency data even for private images, pass --force to cosign below.
87+
# https://github.com/sigstore/cosign
88+
- name: Sign the published Docker image
89+
if: ${{ github.event_name != 'pull_request' }}
90+
env:
91+
# 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 }}
94+
# This step uses the identity token to provision an ephemeral certificate
95+
# against the sigstore community Fulcio instance.
96+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)