9
9
- cron : 00 4 * * *
10
10
11
11
jobs :
12
- php7 :
12
+ build :
13
13
runs-on : ubuntu-latest
14
14
15
+ name : Build Docker image
16
+ strategy :
17
+ matrix :
18
+ php :
19
+ - php7
20
+ - php8
21
+
15
22
steps :
16
23
- name : GitHub Environment Variables Action
17
24
uses : FranzDiebold/github-env-vars-action@v2
18
25
19
26
- name : Shallow clone code
20
- uses : actions/checkout@v3
27
+ uses : actions/checkout@v4
21
28
with :
22
29
fetch-depth : 0
23
30
24
31
- name : Login to Container Registry ghcr.io
25
- uses : docker/login-action@v2
32
+ uses : docker/login-action@v3
26
33
with :
27
34
registry : ghcr.io
28
- username : ${{ github.actor }}
35
+ username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
29
36
password : ${{ secrets.GITHUB_TOKEN }}
30
37
31
- # php7
32
- # tag with temp tag to make sure trivy scans the new version
33
38
- name : Build the container image
34
- run : docker build . --tag php-docker-base:trivytemp --file Dockerfile.php7
39
+ run : docker build . --tag php-docker-base:trivytemp --file Dockerfile.${{ matrix.php }}
35
40
36
41
- name : Run Trivy vulnerability scanner
37
42
uses : aquasecurity/trivy-action@master
@@ -44,84 +49,27 @@ jobs:
44
49
severity : ' CRITICAL,HIGH'
45
50
46
51
- name : Retag new image with latest tag so we can push the scanned version
47
- run : docker image tag php-docker-base:trivytemp ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest
48
-
49
- - name : Push with latest tag
50
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest
51
- - name : Retag new image with commit hash
52
- run : docker image tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:$(echo ${GITHUB_SHA} | cut -c1-8)
53
- - name : Push with commit hash tag
54
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:$(echo ${GITHUB_SHA} | cut -c1-8)
55
- - name : Retag new image with php7 tag
56
- run : docker image tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7
57
- - name : Push with commit php7 tag
58
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7
59
-
60
- # php7-review
61
- - name : Build the PHP7 review container image
62
- run : docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7-review --file Dockerfile.php7-review
63
- - name : Push with commit php7-review tag
64
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7-review
65
-
66
- php8 :
67
- runs-on : ubuntu-latest
68
- steps :
69
- - name : GitHub Environment Variables Action
70
- uses : FranzDiebold/github-env-vars-action@v2
71
-
72
- - name : Shallow clone code
73
- uses : actions/checkout@v3
74
- with :
75
- fetch-depth : 0
76
-
77
- - name : Login to Container Registry ghcr.io
78
- uses : docker/login-action@v2
79
- with :
80
- registry : ghcr.io
81
- username : ${{ github.actor }}
82
- password : ${{ secrets.GITHUB_TOKEN }}
83
-
84
- # php8
85
- - name : Build the container image
86
- run : docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8 --file Dockerfile.php8
87
- - name : Run Trivy vulnerability scanner
88
- uses : aquasecurity/trivy-action@master
89
- with :
90
- image-ref : ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8
91
- format : ' table'
92
- exit-code : ' 1'
93
- ignore-unfixed : true
94
- vuln-type : ' os,library'
95
- severity : ' CRITICAL,HIGH'
96
- - name : Push with php8 tag
97
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8
98
- - name : Retag new image with commit hash
99
- run : docker image tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8 ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-$(echo ${GITHUB_SHA} | cut -c1-8)
100
- - name : Push with commit hash tag and php8 tag
101
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-$(echo ${GITHUB_SHA} | cut -c1-8)
52
+ run : docker image tag php-docker-base:trivytemp ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}
102
53
103
- # php8-review
104
- - name : Build the PHP8 review container image
105
- run : docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-review --file Dockerfile.php8-review
106
- - name : Push with commit php8-review tag
107
- run : docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-review
54
+ - name : Push with commit ${{ matrix.php }} tag
55
+ run : docker push ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}
108
56
109
57
cleanup :
110
- needs : [php7, php8 ]
58
+ needs : [build ]
111
59
runs-on : ubuntu-latest
112
60
steps :
113
61
- name : GitHub Environment Variables Action
114
62
uses : FranzDiebold/github-env-vars-action@v2
115
63
116
64
- name : Login to Container Registry ghcr.io
117
- uses : docker/login-action@v2
65
+ uses : docker/login-action@v3
118
66
with :
119
67
registry : ghcr.io
120
- username : ${{ github.actor }}
68
+ username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
121
69
password : ${{ secrets.GITHUB_TOKEN }}
122
70
123
71
- name : Delete old versions of the package, keeping a few of the newest
124
- uses : actions/delete-package-versions@v4
72
+ uses : actions/delete-package-versions@v5
125
73
with :
126
74
package-name : ${{ env.CI_REPOSITORY_NAME }}
127
75
package-type : container
0 commit comments