Skip to content

Commit 3c6efbf

Browse files
wip
Signed-off-by: Spencer Schrock <[email protected]>
1 parent 72803a1 commit 3c6efbf

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Delete untagged GHCR images
2+
on:
3+
schedule:
4+
- cron: '34 12 * * *' # Daily at 12:34.
5+
workflow_dispatch:
6+
7+
permissions: {}
8+
9+
jobs:
10+
delete-untagged:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
packages: write
14+
steps:
15+
- uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
16+
with:
17+
package-name: 'scorecard-action'
18+
package-type: 'container'
19+
# keep official releases
20+
delete-only-untagged-versions: 'true'
21+
# 'latest' counts as a tag, so this won't break the e2e tests
22+
min-versions-to-keep: 0

.github/workflows/ghcr.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish GitHub Container Registry
2+
on:
3+
push:
4+
branches: ['ghcr']
5+
tags:
6+
- v*
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
# pushes to the default branch get labeled latest, otherwise use tag name
39+
tags: |
40+
type=raw,value=latest,enable={{is_default_branch}}
41+
type=ref,event=tag
42+
43+
- name: Build and push Docker image
44+
id: push
45+
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
46+
with:
47+
context: .
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
52+
- name: Generate artifact attestation
53+
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
54+
# only publish attestation for our release builds
55+
if: startsWith(github.ref, 'refs/tags/v')
56+
with:
57+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
58+
subject-digest: ${{ steps.push.outputs.digest }}
59+
push-to-registry: true

0 commit comments

Comments
 (0)