-
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (80 loc) · 2.66 KB
/
docker-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Docker Build and Publish
on:
push:
branches: [ main ]
release:
types: [ published ]
env:
GHCR_IMAGE: ghcr.io/${{ github.repository }}
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/gpu-monitor
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write # Needed for provenance signing
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.GHCR_IMAGE }}
${{ env.DOCKER_IMAGE }}
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix={{date 'YYYYMMDD'}}-
labels: |
org.opencontainers.image.title=GPU Monitor
org.opencontainers.image.description=Real-time NVIDIA GPU monitoring dashboard
org.opencontainers.image.vendor=${{ github.repository_owner }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
sbom: true
provenance: mode=max
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Export SBOM
run: |
mkdir -p sbom
# Wait a moment for the image to be available
sleep 10
DIGEST=$(docker buildx imagetools inspect ${{ env.GHCR_IMAGE }}:main --raw)
echo "Image digest: $DIGEST"
docker buildx imagetools inspect ${{ env.GHCR_IMAGE }}@$DIGEST \
--format '{{ json .SBOM }}' > sbom/bom.json || echo "SBOM export failed but continuing"
# Optional: Upload SBOM
- name: Upload SBOM
uses: actions/upload-artifact@v3
with:
name: sbom
path: sbom/bom.json
retention-days: 5