-
Notifications
You must be signed in to change notification settings - Fork 6
116 lines (98 loc) · 4 KB
/
ci.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
name: CI
on:
push:
branches:
- 'release/**'
pull_request:
jobs:
ci:
name: Build PHP Image
runs-on: ubuntu-latest
continue-on-error: false
steps:
- name: "Checkout code"
uses: actions/checkout@v3
- name: Lint Dockerfile
uses: hadolint/hadolint-action@v3.0.0
with:
dockerfile: "Dockerfile"
format: "tty"
no-color: "true"
output-file: "/dev/stdout"
- name: "Build Alpine"
run: >
./build_images.sh temporary-build-image
- name: "PHP_VERSION Env"
run: echo "PHP_VERSION=`docker run --pull=never --rm -t temporary-build-image-linux-amd64 php --version | head -n 1 | cut -f 2 -d ' '`" >> $GITHUB_ENV
- name: Tag also with php:${{ env.PHP_VERSION }}
run: docker tag temporary-build-image-linux-amd64 php-${{ env.PHP_VERSION }}
- name: "Check Alpine -i"
run: docker run --pull=never --rm -t php-${{ env.PHP_VERSION }} php -i
- name: "Check Alpine -v"
run: docker run --pull=never --rm -t php-${{ env.PHP_VERSION }} php -v
- name: "Run Tests"
run: tests/run_tests.sh
env:
DOCKER_REGISTRY_IMAGE: "temporary-build-image-linux-amd64"
- name: Run Alpine Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.24.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
with:
image-ref: php-${{ env.PHP_VERSION }}
format: 'table'
exit-code: '0' # we don't break the build if vulnerabilities are included!
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- if: contains(github.ref, 'refs/heads/release/')
name: Run Alpine Trivy vulnerability scanner and upload to github security tab
uses: aquasecurity/trivy-action@0.24.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
with:
image-ref: php-${{ env.PHP_VERSION }}
format: 'sarif'
output: 'trivy-results.sarif'
- if: contains(github.ref, 'refs/heads/release/')
name: Upload Sarif results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
#
- if: contains(github.ref, 'refs/heads/release/')
name: Run Trivy in GitHub SBOM mode and submit results to Dependency Snapshots
uses: aquasecurity/trivy-action@0.24.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
with:
format: 'github'
output: 'dependency-results.sbom.json'
image-ref: 'temporary-build-image-linux-amd64'
github-pat: ${{ secrets.PAT }}
- if: contains(github.ref, 'refs/heads/release/')
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- if: contains(github.ref, 'refs/heads/release/')
name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- if: contains(github.ref, 'refs/heads/release/')
name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- if: contains(github.ref, 'refs/heads/release/')
name: "Build and Push Multi Arch PHP"
env:
GHCR_DOCKER_IMAGE_NAME: ghcr.io/endava/docker-php:${{ env.PHP_VERSION }}
QUAY_DOCKER_IMAGE_NAME: quay.io/endava/php:${{ env.PHP_VERSION }}
run: ./build_and_push_multi_arch_images.sh endava/php:${{ env.PHP_VERSION }}