Skip to content

Commit 91b382a

Browse files
authored
Add release workflow for building and releasing image (#2)
This build the image and releases it as an `ghcr.io` artifact in the GitHub repository.
1 parent 0953863 commit 91b382a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
workflow_dispatch:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
attestations: write
19+
id-token: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34+
- name: Build and push Docker image
35+
id: push
36+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
37+
with:
38+
context: .
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}
42+
- name: Generate artifact attestation
43+
uses: actions/attest-build-provenance@v1
44+
with:
45+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
46+
subject-digest: ${{ steps.push.outputs.digest }}
47+
push-to-registry: true

0 commit comments

Comments
 (0)