Skip to content

Commit 29bff9b

Browse files
committed
Create docker-publish.yml
1 parent 949ee6b commit 29bff9b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Docker Image Build and Publish
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *'
6+
push:
7+
branches: [ "main" ]
8+
tags: [ 'v*' ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
name: Build and Push Docker Image
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
id-token: write
22+
attestations: write
23+
artifact-metadata: write
24+
steps:
25+
- name: Checkout Repository
26+
uses: actions/checkout@v6
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
- name: Log in to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Extract Docker Image Metadata
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=raw,value=latest
42+
type=ref,event=tag
43+
- name: Build and Push Docker Image
44+
id: push
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
cache-from: type=gha
52+
cache-to: type=gha,mode=max
53+
- name: Generate Build Attestation (SLSA)
54+
uses: actions/attest-build-provenance@v3
55+
with:
56+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
subject-digest: ${{ steps.push.outputs.digest }}
58+
push-to-registry: true
59+
- name: Clean up Old Images in GHCR
60+
uses: quartx-analytics/ghcr-cleaner@v1
61+
with:
62+
owner-type: user
63+
token: ${{ secrets.PAT_TOKEN }}
64+
package-name: mkdocs-exporter
65+
delete-untagged: true
66+
keep-at-most: 5
67+
skip-tags: v*,latest

0 commit comments

Comments
 (0)