8
8
- ' docs/**'
9
9
- ' examples/**'
10
10
- ' **.md'
11
+ tags :
12
+ - ' v[0-9]+.[0-9]+.[0-9]+'
11
13
pull_request :
12
14
branches :
13
15
- master
19
21
- ' docs/**'
20
22
- ' examples/**'
21
23
- ' **.md'
22
- create :
23
- tags :
24
- - ' v[0-9]+.[0-9]+.[0-9]+*'
25
24
26
25
env :
27
26
DOCKER_BUILDKIT : 1
28
27
28
+ concurrency :
29
+ group : ${{ github.ref_name }}-ci
30
+ cancel-in-progress : true
31
+
29
32
jobs :
30
33
31
34
vars :
@@ -34,21 +37,15 @@ jobs:
34
37
outputs :
35
38
sha_short : ${{ steps.vars.outputs.sha }}
36
39
go_version : ${{ steps.vars.outputs.go_version }}
37
- git_tag : ${{ steps.vars.outputs.git_tag }}
38
40
repo_name : ${{ steps.vars.outputs.repo }}
39
41
steps :
40
- - name : Cancel Previous Runs
41
-
42
- with :
43
- access_token : ${{ secrets.GITHUB_TOKEN }}
44
42
- name : Checkout Repository
45
43
uses : actions/checkout@v2
46
44
- name : Output Variables
47
45
id : vars
48
46
run : |
49
47
echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
50
48
echo "::set-output name=go_version::$(grep "go 1." go.mod | cut -d " " -f 2)"
51
- echo "::set-output name=git_tag::$(echo ${GITHUB_REF/refs\/tags\//} | tr -d v)"
52
49
echo "::set-output name=repo::$(echo ${GITHUB_REPOSITORY} | cut -d '/' -f 2)"
53
50
54
51
binary :
@@ -96,23 +93,43 @@ jobs:
96
93
with :
97
94
path : ${{ github.workspace }}/bin/manager
98
95
key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
96
+ - name : DockerHub Login
97
+ uses : docker/login-action@v1
98
+ with :
99
+ username : ${{ secrets.DOCKER_USERNAME }}
100
+ password : ${{ secrets.DOCKER_PASSWORD }}
101
+ if : github.event_name != 'pull_request'
99
102
- name : Docker Buildx
100
103
uses : docker/setup-buildx-action@v1
104
+ - name : Docker meta
105
+ id : meta
106
+ uses : docker/metadata-action@v3
107
+ with :
108
+ images : |
109
+ nginx/nginx-ingress-operator
110
+ tags : |
111
+ type=edge
112
+ type=ref,event=pr
113
+ type=semver,pattern={{version}}
114
+ labels : |
115
+ org.opencontainers.image.documentation=https://docs.nginx.com/nginx-ingress-controller
116
+ org.opencontainers.image.vendor=NGINX Inc <[email protected] >
101
117
- name : Build Image
102
118
uses : docker/build-push-action@v2
103
119
with :
104
120
context : ' .'
105
121
cache-from : type=gha
106
122
cache-to : type=gha,mode=max
107
- tags : nginx/nginx-ingress-operator:${{ github.sha }}
108
- push : false
123
+ tags : ${{ steps.meta.outputs.tags }}
124
+ labels : ${{ steps.meta.outputs.labels }}
125
+ load : ${{ github.event_name == 'pull_request' }}
126
+ push : ${{ github.event_name != 'pull_request' }}
109
127
pull : true
110
- load : true
111
128
- name : Run Trivy vulnerability scanner
112
- uses :
aquasecurity/[email protected] .0
129
+ uses :
aquasecurity/[email protected] .1
113
130
continue-on-error : true
114
131
with :
115
- image-ref : nginx/nginx-ingress-operator:${{ github.sha }}
132
+ image-ref : nginx/nginx-ingress-operator:${{ steps.meta.outputs.version }}
116
133
format : ' template'
117
134
template : ' @/contrib/sarif.tpl'
118
135
output : ' trivy-results.sarif'
@@ -121,7 +138,7 @@ jobs:
121
138
uses : github/codeql-action/upload-sarif@v1
122
139
continue-on-error : true
123
140
with :
124
- sarif_file : ' trivy-result .sarif'
141
+ sarif_file : ' trivy-results .sarif'
125
142
- name : Upload Scan Results
126
143
uses : actions/upload-artifact@v2
127
144
continue-on-error : true
@@ -130,46 +147,11 @@ jobs:
130
147
path : ' trivy-results.sarif'
131
148
if : always()
132
149
133
- release-docker :
134
- name : Release Image
135
- runs-on : ubuntu-20.04
136
- needs : [vars, build, unit-tests]
137
- if :
138
- github.repository == 'nginxinc/nginx-ingress-operator' &&
139
- github.event_name == 'create' &&
140
- contains(github.ref, 'refs/tags/')
141
- steps :
142
- - name : Checkout Repository
143
- uses : actions/checkout@v2
144
- - name : Fetch Cached Artifacts
145
- uses : actions/cache@v2
146
- with :
147
- path : ${{ github.workspace }}/build/_output/bin/nginx-ingress-operator
148
- key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
149
- - name : Docker Buildx
150
- uses : docker/setup-buildx-action@v1
151
- - name : DockerHub Login
152
- uses : docker/login-action@v1
153
- with :
154
- username : ${{ secrets.DOCKER_USERNAME }}
155
- password : ${{ secrets.DOCKER_PASSWORD }}
156
- - name : Push to Dockerhub
157
- uses : docker/build-push-action@v2
158
- with :
159
- file : Dockerfile
160
- context : ' .'
161
- cache-from : type=gha
162
- cache-to : type=gha,mode=max
163
- tags : |
164
- nginx/nginx-ingress-operator:latest
165
- nginx/nginx-ingress-operator:${{ needs.vars.outputs.git_tag }}
166
- push : true
167
- pull : true
168
150
169
151
notify :
170
152
name : Notify
171
153
runs-on : ubuntu-20.04
172
- needs : [vars, release-docker ]
154
+ needs : [vars, build ]
173
155
if : always() && github.ref == 'refs/heads/master'
174
156
steps :
175
157
- name : Workflow Status
0 commit comments