generated from linkorb/.github
-
Notifications
You must be signed in to change notification settings - Fork 4
128 lines (110 loc) · 4.95 KB
/
production.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
117
118
119
120
121
122
123
124
125
126
127
128
name: BuildContainerForProduction
on:
workflow_dispatch:
push:
branches:
- master
schedule:
- cron: 00 4 * * *
jobs:
php7:
runs-on: ubuntu-latest
steps:
- name: GitHub Environment Variables Action
uses: FranzDiebold/github-env-vars-action@v2
- name: Shallow clone code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Container Registry ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#php7
#tag with temp tag to make sure trivy scans the new version
- name: Build the container image
run: docker build . --tag php-docker-base:trivytemp --file Dockerfile.php7
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: php-docker-base:trivytemp
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- name: Retag new image with latest tag so we can push the scanned version
run: docker image tag php-docker-base:trivytemp ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest
- name: Push with latest tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest
- name: Retag new image with commit hash
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)
- name: Push with commit hash tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:$(echo ${GITHUB_SHA} | cut -c1-8)
- name: Retag new image with php7 tag
run: docker image tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:latest ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7
- name: Push with commit php7 tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7
#php7-review
- name: Build the PHP7 review container image
run: docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7-review --file Dockerfile.php7-review
- name: Push with commit php7-review tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php7-review
php8:
runs-on: ubuntu-latest
steps:
- name: GitHub Environment Variables Action
uses: FranzDiebold/github-env-vars-action@v2
- name: Shallow clone code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Container Registry ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#php8
- name: Build the container image
run: docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8 --file Dockerfile.php8
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- name: Push with php8 tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8
- name: Retag new image with commit hash
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)
- name: Push with commit hash tag and php8 tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-$(echo ${GITHUB_SHA} | cut -c1-8)
#php8-review
- name: Build the PHP8 review container image
run: docker build . --tag ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-review --file Dockerfile.php8-review
- name: Push with commit php8-review tag
run: docker push ghcr.io/${{ github.repository_owner }}/${{ env.CI_REPOSITORY_NAME }}:php8-review
cleanup:
needs: [php7, php8]
runs-on: ubuntu-latest
steps:
- name: GitHub Environment Variables Action
uses: FranzDiebold/github-env-vars-action@v2
- name: Login to Container Registry ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Delete old versions of the package, keeping a few of the newest
uses: actions/delete-package-versions@v4
with:
package-name: ${{ env.CI_REPOSITORY_NAME }}
package-type: container
min-versions-to-keep: 8