99 - cron : 00 4 * * *
1010
1111jobs :
12- php7 :
12+ build :
1313 runs-on : ubuntu-latest
1414
15+ name : Build Docker image
16+ strategy :
17+ matrix :
18+ php :
19+ - php7
20+ - php8
21+
1522 steps :
1623 - name : GitHub Environment Variables Action
1724 uses : FranzDiebold/github-env-vars-action@v2
1825
1926 - name : Shallow clone code
20- uses : actions/checkout@v3
27+ uses : actions/checkout@v4
2128 with :
2229 fetch-depth : 0
2330
2431 - name : Login to Container Registry ghcr.io
25- uses : docker/login-action@v2
32+ uses : docker/login-action@v3
2633 with :
2734 registry : ghcr.io
28- username : ${{ github.actor }}
35+ username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
2936 password : ${{ secrets.GITHUB_TOKEN }}
3037
31- # php7
32- # tag with temp tag to make sure trivy scans the new version
3338 - 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 }}
3540
3641 - name : Run Trivy vulnerability scanner
3742 uses : aquasecurity/trivy-action@master
@@ -44,84 +49,27 @@ jobs:
4449 severity : ' CRITICAL,HIGH'
4550
4651 - 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 }}
10253
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 }}
10856
10957 cleanup :
110- needs : [php7, php8 ]
58+ needs : [build ]
11159 runs-on : ubuntu-latest
11260 steps :
11361 - name : GitHub Environment Variables Action
11462 uses : FranzDiebold/github-env-vars-action@v2
11563
11664 - name : Login to Container Registry ghcr.io
117- uses : docker/login-action@v2
65+ uses : docker/login-action@v3
11866 with :
11967 registry : ghcr.io
120- username : ${{ github.actor }}
68+ username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
12169 password : ${{ secrets.GITHUB_TOKEN }}
12270
12371 - 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
12573 with :
12674 package-name : ${{ env.CI_REPOSITORY_NAME }}
12775 package-type : container
0 commit comments