Repository navigation
137 lines (115 loc) · 3.73 KB
/
Copy pathdocker.yml
File metadata and controls
137 lines (115 loc) · 3.73 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Docker Image
on:
schedule:
- cron: "0 10 * * *" # everyday at 10am
pull_request:
branches: ["latest"]
push:
branches: ["latest"]
tags: ["v*.*.*"]
env:
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/s390x,linux/ppc64le
jobs:
main:
runs-on: ubuntu-22.04
timeout-minutes: 20
permissions:
contents: read
packages: write
pull-requests: write
security-events: write
id-token: write
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v7
with:
ref: ${{ github.head_ref || github.ref }}
- name: Hadolint
uses: hadolint/hadolint-action@v3.5.0
with:
dockerfile: ./Dockerfile
config: .github/hadolint.yaml
- name: Set imageName based on the repository name
id: step_one
run: |
imageName="${GITHUB_REPOSITORY/docker-/}"
echo $imageName
echo "imageName=$imageName" >> $GITHUB_ENV
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v6
with:
images: ${{ env.imageName }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v4.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build for PR
id: docker_build_pr
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
pull: true
load: true
tags: |
${{ steps.docker_meta.outputs.tags }}
${{ env.imageName }}:pr-${{ github.event.number }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Build and push
id: docker_build
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: ${{ env.platforms }}
push: true
pull: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
attests: |
type=sbom
type=provenance,mode=max
- name: Container Structure Tests
if: ${{ github.event_name == 'pull_request' }}
uses: plexsystems/container-structure-test-action@v0.3.0
with:
image: ${{ env.imageName }}:pr-${{ github.event.number }}
config: .github/cst.yaml
- name: Cosign install
if: ${{ github.event_name != 'pull_request' }}
uses: sigstore/cosign-installer@v3
- name: Sign image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
run: |
cosign sign --yes ${{ env.imageName }}@${{ steps.docker_build.outputs.digest }}
- name: Docker Scout
id: docker-scout-cves
if: ${{ github.event_name != 'pull_request' }}
uses: docker/scout-action@v1.26.0
with:
command: cves
organization: beevelop
image: ${{ env.imageName }}:latest
to-latest: true
github-token: ${{ secrets.GITHUB_TOKEN }}
sarif-file: sarif.output.json
- name: Upload SARIF result
id: upload-sarif
if: ${{ github.event_name != 'pull_request' }}
uses: github/codeql-action/upload-sarif@v4.38.2
with:
sarif_file: sarif.output.json