This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (135 loc) · 4.21 KB
/
docker.image.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
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
138
name: Docker Image CI
on:
push:
branches:
- $default-branch
- development
- master
tags:
- '*.*.*-*'
# Run tests for any PRs
pull_request:
schedule:
- cron: '43 10 * * 4'
env:
IMAGE_NAME: infcloud
jobs:
codespell:
name: codespell
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Codespell
uses: codespell-project/actions-codespell@master
with:
skip: .git
check_filenames: true
check_hidden: true
super-linter:
name: super-linter
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Lint Code Base
uses: github/super-linter@v4.7.3
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shiftleft:
name: shiftleft
runs-on: ubuntu-latest
steps:
- name: Perform ShiftLeft Scan
uses: ShiftLeftSecurity/scan-action@master
env:
WORKSPACE: ""
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCAN_AUTO_BUILD: true
with:
output: reports
# Scan auto-detects the languages in your project. To override uncomment the below variable and set the type
# type: credscan,java
# type: python
- name: Upload report
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: reports
build:
needs:
- codespell
- super-linter
- shiftleft
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: linux/amd64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build the Docker image
id: docker_test
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: localhost:5000/foobar/${{ env.IMAGE_NAME }}
context: .
file: ./Dockerfile
platforms: linux/amd64
build-args: |
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
BUILD_VERSION="$(git describe --tags)"
VCS_REF="$(git rev-parse --short HEAD)"
VCS_URL="$(git config --get remote.origin.url)"
VCS_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
- name: Inspect the Docker image
run: |
docker buildx imagetools inspect localhost:5000/foobar/${{ env.IMAGE_NAME }}
- name: Compose up
run: docker-compose -f .github/docker-compose.yml up -d
- name: Check running containers
run: docker ps -a
- name: Check logs
run: docker-compose -f .github/docker-compose.yml logs
- name: Test the Docker image
run: if ! [ "$(docker ps -a | grep "${IMAGE_NAME}" | head -1 | grep -c "${IMAGE_NAME}")" = "1" ]; then exit 1; fi
- name: Compose down
run: docker-compose -f .github/docker-compose.yml down
- name: Scan image with Container Scan
uses: Azure/container-scan@v0
env:
DOCKER_CONTENT_TRUST: 1
with:
image-name: localhost:5000/foobar/${{ env.IMAGE_NAME }}
severity-threshold: HIGH
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: localhost:5000/foobar/${{ env.IMAGE_NAME }}
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Run the Anchore scan action itself with GitHub Advanced Security code scanning integration enabled
uses: anchore/scan-action@main
with:
image: localhost:5000/foobar/${{ env.IMAGE_NAME }}
acs-report-enable: true
- name: Move reports
run: mkdir -p sarif-reports && cp ./*results.sarif ./sarif-reports/
- name: Upload Reports
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'sarif-reports'