@@ -20,64 +20,59 @@ jobs:
2020 - php8
2121
2222 steps :
23- - name : GitHub Environment Variables Action
24- uses : FranzDiebold/github-env-vars-action@v2
23+ - name : Shallow clone code
24+ uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0
2527
26- - name : Shallow clone code
27- uses : actions/checkout@v4
28- with :
29- fetch-depth : 0
28+ - name : Login to Container Registry ghcr.io
29+ uses : docker/login-action@v3
30+ with :
31+ registry : ghcr.io
32+ username : ${{ github.repository_owner }} # ghcr logins allow mixed case usernames
33+ password : ${{ secrets.GITHUB_TOKEN }}
3034
31- - name : Login to Container Registry ghcr.io
32- uses : docker/login-action@v3
33- with :
34- registry : ghcr.io
35- username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
36- password : ${{ secrets.GITHUB_TOKEN }}
35+ - name : Build the container image
36+ run : docker build . --tag php-docker-base:trivytemp --file Dockerfile.${{ matrix.php }}
3737
38- - name : Build the container image
39- run : docker build . --tag php-docker-base:trivytemp --file Dockerfile.${{ matrix.php }}
38+ - name : Run Trivy vulnerability scanner
39+ uses : aquasecurity/trivy-action@master
40+ with :
41+ image-ref : php-docker-base:trivytemp
42+ format : ' table'
43+ exit-code : ' 1'
44+ ignore-unfixed : true
45+ vuln-type : ' os,library'
46+ severity : ' CRITICAL,HIGH'
4047
41- - name : Run Trivy vulnerability scanner
42- uses : aquasecurity/trivy-action@master
43- with :
44- image-ref : php-docker-base:trivytemp
45- format : ' table'
46- exit-code : ' 1'
47- ignore-unfixed : true
48- vuln-type : ' os,library'
49- severity : ' CRITICAL,HIGH'
48+ - name : Retag new image with latest tag so we can push the scanned version
49+ run : docker image tag php-docker-base:trivytemp "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}"
5050
51- - name : Retag new image with latest tag so we can push the scanned version
52- run : docker image tag php-docker-base:trivytemp ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/ ${{ env.CI_REPOSITORY_NAME }}: ${{ matrix.php }}
51+ - name : Push with commit ${{ matrix.php }} tag
52+ run : docker push " ghcr.io/$(echo ' ${{ github.repository }}' | tr '[:upper:]' '[:lower:]'): ${{ matrix.php }}"
5353
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 }}
56-
57- # review containers
58- - name : Build the review container image
59- run : docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}-review --file Dockerfile.${{ matrix.php }}-review
60- - name : Push with commit *-review tag
61- run : docker push ghcr.io/${{ env.CI_REPOSITORY_OWNER_SLUG }}/${{ env.CI_REPOSITORY_NAME }}:${{ matrix.php }}-review
54+ # review containers
55+ - name : Build the review container image
56+ run : docker build . --tag "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review" --file Dockerfile.${{ matrix.php }}-review
6257
58+ - name : Push with commit *-review tag
59+ run : docker push "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review"
6360
6461 cleanup :
6562 needs : [build]
6663 runs-on : ubuntu-latest
6764 steps :
68- - name : GitHub Environment Variables Action
69- uses : FranzDiebold/github-env-vars-action@v2
7065
71- - name : Login to Container Registry ghcr.io
72- uses : docker/login-action@v3
73- with :
74- registry : ghcr.io
75- username : ${{ env.CI_REPOSITORY_OWNER_SLUG }}
76- password : ${{ secrets.GITHUB_TOKEN }}
66+ - name : Login to Container Registry ghcr.io
67+ uses : docker/login-action@v3
68+ with :
69+ registry : ghcr.io
70+ username : ${{ github.repository_owner }} # ghcr logins allow mixed case usernames
71+ password : ${{ secrets.GITHUB_TOKEN }}
7772
78- - name : Delete old versions of the package, keeping a few of the newest
79- uses : actions/delete-package-versions@v5
80- with :
81- package-name : ${{ env.CI_REPOSITORY_NAME }}
82- package-type : container
83- min-versions-to-keep : 8
73+ - name : Delete old versions of the package, keeping a few of the newest
74+ uses : actions/delete-package-versions@v5
75+ with :
76+ package-name : ${{ github.event.repository.name }}
77+ package-type : container
78+ min-versions-to-keep : 8
0 commit comments