Skip to content

Commit 1cc17f1

Browse files
authored
Update docker-publish.yml
1 parent 0606cb9 commit 1cc17f1

File tree

1 file changed

+19
-68
lines changed

1 file changed

+19
-68
lines changed
Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,44 @@
1-
name: Docker
2-
3-
# This workflow uses actions that are not certified by GitHub.
4-
# They are provided by a third-party and are governed by
5-
# separate terms of service, privacy policy, and support
6-
# documentation.
1+
name: Build and Push Docker Image
72

83
on:
94
push:
10-
# Publish semver tags as releases.
11-
tags: [ 'v*.*.*' ]
5+
tags:
6+
- '*'
127

138
env:
14-
# Use docker.io for Docker Hub if empty
159
REGISTRY: ghcr.io
16-
# github.repository as <account>/<repo>
1710
IMAGE_NAME: ${{ github.repository }}
1811

19-
2012
jobs:
21-
build:
22-
13+
build-and-push:
2314
runs-on: ubuntu-latest
24-
permissions:
25-
contents: read
26-
packages: write
27-
# This is used to complete the identity challenge
28-
# with sigstore/fulcio when running outside of PRs.
29-
id-token: write
3015

3116
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v3
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
3419

35-
# Install the cosign tool except on PR
36-
# https://github.com/sigstore/cosign-installer
37-
- name: Install cosign
38-
if: github.event_name != 'pull_request'
39-
uses: sigstore/cosign-installer@v3.7.0
40-
with:
41-
cosign-release: 'v2.4.1'
42-
43-
# Set up BuildKit Docker container builder to be able to build
44-
# multi-platform images and export cache
45-
# https://github.com/docker/setup-buildx-action
4620
- name: Set up Docker Buildx
47-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
21+
uses: docker/setup-buildx-action@v3
4822

49-
# Login against a Docker registry except on PR
50-
# https://github.com/docker/login-action
51-
- name: Log into registry ${{ env.REGISTRY }}
52-
if: github.event_name != 'pull_request'
53-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
23+
- name: Log in to GitHub Container Registry
24+
uses: docker/login-action@v3
5425
with:
5526
registry: ${{ env.REGISTRY }}
5627
username: ${{ github.actor }}
5728
password: ${{ secrets.GITHUB_TOKEN }}
5829

59-
# Extract metadata (tags, labels) for Docker
60-
# https://github.com/docker/metadata-action
61-
- name: Extract Docker metadata
62-
id: meta
63-
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
64-
with:
65-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
30+
- name: Extract Tag Name
31+
id: extract_tag
32+
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
6633

67-
# Build and push Docker image with Buildx (don't push on PR)
68-
# https://github.com/docker/build-push-action
69-
- name: Build and push Docker image
70-
id: build-and-push
71-
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
34+
- name: Build and Push Docker Image (Multi-Arch)
35+
uses: docker/build-push-action@v5
7236
with:
7337
context: .
74-
push: ${{ github.event_name != 'pull_request' }}
75-
tags: ${{ steps.meta.outputs.tags }}
76-
labels: ${{ steps.meta.outputs.labels }}
38+
push: true
39+
platforms: linux/amd64, linux/arm64, linux/arm/v7, windows/amd64, darwin/amd64
40+
tags: |
41+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
42+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
7743
cache-from: type=gha
7844
cache-to: type=gha,mode=max
79-
80-
# Sign the resulting Docker image digest except on PRs.
81-
# This will only write to the public Rekor transparency log when the Docker
82-
# repository is public to avoid leaking data. If you would like to publish
83-
# transparency data even for private images, pass --force to cosign below.
84-
# https://github.com/sigstore/cosign
85-
- name: Sign the published Docker image
86-
if: ${{ github.event_name != 'pull_request' }}
87-
env:
88-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
89-
TAGS: ${{ steps.meta.outputs.tags }}
90-
DIGEST: ${{ steps.build-and-push.outputs.digest }}
91-
# This step uses the identity token to provision an ephemeral certificate
92-
# against the sigstore community Fulcio instance.
93-
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)