Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit e93268c

Browse files
authored
chore: add nightly job and move security scan, upload results to github security (#692)
* chore: add nightly job and move security scan, upload results to github security Signed-off-by: Markus Maga <[email protected]> * chore: only trigger branch trigger for master branch Signed-off-by: Markus Maga <[email protected]>
1 parent e43a6b8 commit e93268c

File tree

2 files changed

+78
-24
lines changed

2 files changed

+78
-24
lines changed

.github/workflows/build-container.yaml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: docker
33
on:
44
push:
55
branches:
6-
- '**'
6+
- 'master'
77
tags:
88
- '*.*.*'
99
pull_request:
@@ -45,14 +45,17 @@ jobs:
4545
4646
- name: Docker meta
4747
id: docker_meta
48-
uses: crazy-max/ghaction-docker-meta@v1
48+
uses: crazy-max/ghaction-docker-meta@v2
4949
with:
5050
images: ${{ steps.image_name.outputs.image }}
51-
tag-sha: github.ref != 'refs/heads/master'
51+
tags: |
52+
type=ref,event=tag
53+
type=ref,event=pr
54+
type=edge,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},latest=false
5255
5356
- name: Login to Docker
5457
uses: docker/login-action@v1
55-
if: env.GHCR_USERNAME != ''
58+
if: env.GHCR_USERNAME != '' && steps.docker_meta.outputs.version != ''
5659
with:
5760
registry: ghcr.io
5861
username: ${{ secrets.GHCR_USERNAME }}
@@ -63,25 +66,6 @@ jobs:
6366
with:
6467
context: .
6568
platforms: linux/amd64,linux/arm64,linux/arm/v7
66-
push: ${{ env.GHCR_USERNAME != '' }}
69+
push: ${{ env.GHCR_USERNAME != '' && steps.docker_meta.outputs.version != ''}}
6770
tags: ${{ steps.docker_meta.outputs.tags }}
6871
labels: ${{ steps.docker_meta.outputs.labels }}
69-
70-
# cant load multi arch, so we build the same arch again (everything should cache hit)
71-
- name: Load for scan
72-
uses: docker/build-push-action@v2
73-
id: docker_load
74-
with:
75-
context: .
76-
platforms: linux/amd64
77-
load: true
78-
tags: kes-scan:scan
79-
labels: ${{ steps.docker_meta.outputs.labels }}
80-
81-
- name: Trivy Scan - High and Critical Severity
82-
uses: aquasecurity/[email protected]
83-
with:
84-
image-ref: kes-scan:scan
85-
exit-code: 1
86-
ignore-unfixed: true
87-
severity: HIGH,CRITICAL

.github/workflows/nightly.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: nightly
2+
3+
on:
4+
schedule:
5+
# At 03:07
6+
- cron: '7 3 * * *'
7+
8+
env:
9+
# We can't run a step 'if secrets.GHCR_USERNAME != ""' but we can run a step
10+
# 'if env.GHCR_USERNAME' != ""', so we copy these to test whether credentials
11+
# are available before trying to run steps that need them. Like PRs from forks!
12+
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
13+
IMAGE_NAME: ghcr.io/external-secrets/kubernetes-external-secrets
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v1
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
28+
- name: Docker meta
29+
id: docker_meta
30+
uses: crazy-max/ghaction-docker-meta@v2
31+
with:
32+
images: ${{ env.IMAGE_NAME }}
33+
tags: |
34+
type=schedule,pattern=nightly
35+
36+
- name: Login to Docker
37+
uses: docker/login-action@v1
38+
if: env.GHCR_USERNAME != ''
39+
with:
40+
registry: ghcr.io
41+
username: ${{ secrets.GHCR_USERNAME }}
42+
password: ${{ secrets.GHCR_TOKEN }}
43+
44+
- name: Build nightly
45+
uses: docker/build-push-action@v2
46+
with:
47+
context: .
48+
platforms: linux/amd64,linux/arm64,linux/arm/v7
49+
push: ${{ env.GHCR_USERNAME != '' }}
50+
tags: ${{ steps.docker_meta.outputs.tags }}
51+
labels: ${{ steps.docker_meta.outputs.labels }}
52+
53+
scan:
54+
needs: build
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Run Trivy vulnerability scanner
58+
uses: aquasecurity/trivy-action@master
59+
with:
60+
image-ref: ${{ env.IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}
61+
format: 'template'
62+
ignore-unfixed: true
63+
severity: HIGH,CRITICAL
64+
template: '@/contrib/sarif.tpl'
65+
output: 'trivy-results.sarif'
66+
67+
- name: Upload Trivy scan results to GitHub Security tab
68+
uses: github/codeql-action/upload-sarif@v1
69+
with:
70+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)