-
Notifications
You must be signed in to change notification settings - Fork 102
102 lines (90 loc) · 3.22 KB
/
docker-build.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
name: Docker Image Build
env:
IMAGE_NAME: pegasystems/pega-ready
MAJOR_MINOR: "3.1"
BUILD_NUMBER: $GITHUB_RUN_NUMBER
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 7 * * *'
jobs:
docker-login:
name: Login to DockerHub
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'pegasystems/docker-pega-web-ready' }}
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
test:
name: Container Tests
runs-on: ubuntu-latest
if: always()
needs: docker-login
steps:
- name: Check out working repository
uses: actions/checkout@v2
- name: Run Container Tests
run: |
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64
chmod +x container-structure-test-linux-amd64
sudo mv container-structure-test-linux-amd64 /usr/local/bin/container-structure-test
make test
scan:
name: Scan for CVEs
runs-on: ubuntu-latest
if: always()
needs: docker-login
steps:
- name: Check out working repository
uses: actions/checkout@v2
- name: Build Image
run: make image
- name: Scan image
id: scan
uses: anchore/scan-action@v3
with:
image: "pegasystems/pega-ready:latest"
fail-build: true
severity-cutoff: "high"
acs-report-enable: true
- name: Log Scan Results
if: always()
run: |
echo "Failures:"
cat ${{ steps.scan.outputs.sarif }} | jq '.runs[0].tool.driver.rules[].shortDescription.text' | grep -i "critical" || true
cat ${{ steps.scan.outputs.sarif }} | jq '.runs[0].tool.driver.rules[].shortDescription.text' | grep -i "high" || true
echo "Warnings:"
cat ${{ steps.scan.outputs.sarif }} | jq '.runs[0].tool.driver.rules[].shortDescription.text' | grep -i "medium" || true
cat ${{ steps.scan.outputs.sarif }} | jq '.runs[0].tool.driver.rules[].shortDescription.text' | grep -i "low" || true
cat ${{ steps.scan.outputs.sarif }} | jq '.runs[0].tool.driver.rules[].shortDescription.text' | grep -iv "critical\|high\|medium\|low" || true
- name: Publish Scan Results as Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: docker-scan-results
path: ${{ steps.scan.outputs.sarif }}
- name: Upload Anchore Scan SARIF Report
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
push:
name: Push to DockerHub
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'pegasystems/docker-pega-web-ready' }}
runs-on: ubuntu-latest
needs: [scan, test]
steps:
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check out working repository
uses: actions/checkout@v2
- name: Push image to dockerhub
run: make push