Skip to content

Commit 184fd5a

Browse files
authored
Create docker-publish.yml
1 parent bcfa0f9 commit 184fd5a

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install cosign
24+
if: github.event_name != 'pull_request'
25+
uses: sigstore/cosign-installer@v3.5.0
26+
with:
27+
cosign-release: 'v2.1.1'
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
with:
32+
platforms: linux/amd64,linux/arm64
33+
34+
- name: Log into registry ${{ env.REGISTRY }}
35+
if: github.event_name != 'pull_request'
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
48+
- name: Build and push Docker image
49+
id: build-and-push
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
push: ${{ github.event_name != 'pull_request' }}
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}
56+
cache-from: type=gha
57+
cache-to: type=gha,mode=max
58+
platforms: linux/amd64,linux/arm64
59+
60+
- name: Sign the published Docker image
61+
if: ${{ github.event_name != 'pull_request' }}
62+
env:
63+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
64+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

0 commit comments

Comments
 (0)