-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (110 loc) · 3.93 KB
/
Copy pathbuild-images.yml
File metadata and controls
123 lines (110 loc) · 3.93 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: build-images
# Собирает кастомные образы стека, пушит в GHCR с SBOM+provenance,
# подписывает через cosign (keyless OIDC) и сканирует Trivy (CVE -> Security tab).
on:
push:
branches: [main]
tags: ["v*"]
paths:
- "enrichment/**"
- "fakeflac/**"
- "lidarr-provision/**"
- "prowlarr-provision/**"
- "beets/**"
- "scripts/**"
- ".github/workflows/build-images.yml"
pull_request:
paths:
- "enrichment/**"
- "fakeflac/**"
- "lidarr-provision/**"
- "prowlarr-provision/**"
- "beets/**"
- "scripts/**"
workflow_dispatch:
concurrency:
group: build-images-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
id-token: write # cosign keyless (OIDC)
security-events: write # upload Trivy SARIF
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- enrichment
- fakeflac
- lidarr-provision
- prowlarr-provision
- beets
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ghcr.io/${{ github.repository_owner }}/pwnd-music-${{ matrix.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=semver,pattern={{version}}
type=sha,format=short
- name: Build & push
id: build
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
file: ${{ matrix.image }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
sbom: true
provenance: mode=max
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign image (keyless)
if: github.event_name != 'pull_request'
env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ghcr.io/${{ github.repository_owner }}/pwnd-music-${{ matrix.image }}
run: cosign sign --yes "${IMAGE}@${DIGEST}"
- name: Trivy scan (CVE)
if: github.event_name != 'pull_request'
uses: aquasecurity/trivy-action@476e4fdcdc675b65ce75e8c3440b48d7a494f0e5 # master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/pwnd-music-${{ matrix.image }}@${{ steps.build.outputs.digest }}
format: sarif
output: trivy-${{ matrix.image }}.sarif
severity: CRITICAL,HIGH
ignore-unfixed: true
- name: Upload Trivy SARIF
if: github.event_name != 'pull_request'
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
sarif_file: trivy-${{ matrix.image }}.sarif
category: trivy-${{ matrix.image }}
validate-compose:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Validate docker-compose.yml
run: |
cp .env.example .env
docker compose config --quiet
echo "compose валиден"