Skip to content

Commit 7aae671

Browse files
authored
Clean up docker-publish.yml workflow
Removed comments and cron schedule from Docker publish workflow.
1 parent e30d955 commit 7aae671

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
tags: [ 'v*.*.*' ]
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Install cosign
29+
if: github.event_name != 'pull_request'
30+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
31+
with:
32+
cosign-release: 'v2.2.4'
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
36+
37+
- name: Log into registry ${{ env.REGISTRY }}
38+
if: github.event_name != 'pull_request'
39+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
51+
- name: Build and push Docker image
52+
id: build-and-push
53+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
54+
with:
55+
context: .
56+
push: ${{ github.event_name != 'pull_request' }}
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
62+
- name: Sign the published Docker image
63+
if: ${{ github.event_name != 'pull_request' }}
64+
env:
65+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
66+
TAGS: ${{ steps.meta.outputs.tags }}
67+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
68+
# This step uses the identity token to provision an ephemeral certificate
69+
# against the sigstore community Fulcio instance.
70+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)