Skip to content

Commit 1edee03

Browse files
committed
Create publish.yml
1 parent c2f379e commit 1edee03

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
pull_request:
5+
release:
6+
types: ['published']
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+
There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
Sets the permissions granted to the GITHUB_TOKEN for the actions in this job.
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
- name: Build and push Docker image
38+
id: push
39+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
- name: Generate artifact attestation
46+
uses: actions/attest-build-provenance@v1
47+
with:
48+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
49+
subject-digest: ${{ steps.push.outputs.digest }}
50+
push-to-registry: true

0 commit comments

Comments
 (0)