E58F add release marketplace flags (#5129) · nginx/kubernetes-ingress@ab4037d · GitHub
[go: up one dir, main page]

Skip to content

Commit ab4037d

Browse files
authored
add release marketplace flags (#5129)
* extract marketplace publish logic to ci file * refactor forked workflow logic
1 parent 0cbdf2d commit ab4037d

File tree

4 files changed

+73
-43
lines changed

4 files changed

+73
-43
lines changed

.github/actions/smoke-tests/action.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ inputs:
4444
gcr-service-account-secret:
4545
description: Google Service Account secret
4646
required: false
47+
forked-workflow:
48+
description: Does this workflow full access to repo resources?
49+
required: false
4750

4851
outputs:
4952
test-results-name:
@@ -77,23 +80,23 @@ runs:
7780
token_format: access_token
7881
workload_identity_provider: ${{ inputs.gcr-workload-identity-secret }}
7982
service_account: ${{ inputs.gcr-service-account-secret }}
80-
if: github.event.pull_request.head.repo.full_name == github.repository
83+
if: ${{ ! inputs.forked-workflow }}
8184

8285
- name: Login to GCR
8386
uses: docker/login-action@v3
8487
with:
8588
registry: gcr.io
8689
username: oauth2accesstoken
8790
password: ${{ steps.auth.outputs.access_token }}
88-
if: github.event.pull_request.head.repo.full_name == github.repository
91+
if: ${{ ! inputs.forked-workflow }}
8992

9093
- name: Build ${{ inputs.image }} Container
9194
uses: docker/build-push-action@v3
9295
with:
9396
file: build/Dockerfile
9497
context: "."
9598
cache-from: type=gha,scope=${{ inputs.image }}${{ contains(inputs.marker, 'dos') && '-dos' || '' }}${{ contains(inputs.marker, 'appprotect') && '-nap' || '' }}
96-
target: goreleaser${{ github.event.pull_request.head.repo.full_name == github.repository && '-prebuilt' || '' }}
99+
target: goreleaser${{ ! inputs.forked-workflow && '-prebuilt' || '' }}
97100
tags: "docker.io/nginx/${{ steps.ingress-type.outputs.name }}:${{ steps.ingress-type.outputs.tag }}"
98101
load: true
99102
pull: true
@@ -135,7 +138,7 @@ runs:
135138
tags: ${{ inputs.test-image }}
136139
pull: true
137140
load: true
138-
if: github.event.pull_request.head.repo.full_name != github.repository
141+
if: ${{ inputs.forked-workflow }}
139142

140143
- name: Run Smoke Tests
141144
run: |

.github/workflows/build-oss.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
publish-image:
2222
required: false
2323
type: boolean
24+
forked-workflow:
25+
required: false
26+
type: boolean
2427

2528
defaults:
2629
run:
@@ -105,15 +108,15 @@ jobs:
105108
token_format: access_token
106109
workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }}
107110
service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }}
108-
if: github.event.pull_request.head.repo.full_name == github.repository
111+
if: ${{ ! inputs.forked-workflow }}
109112

110113
- name: Login to GCR
111114
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
112115
with:
113116
registry: gcr.io
114117
username: oauth2accesstoken
115118
password: ${{ steps.auth.outputs.access_token }}
116-
if: github.event.pull_request.head.repo.full_name == github.repository
119+
if: ${{ ! inputs.forked-workflow }}
117120

118121
- name: Get short tag
119122
id: tag
@@ -163,7 +166,7 @@ jobs:
163166
context: "."
164167
cache-from: type=gha,scope=${{ inputs.image }}
165168
cache-to: type=gha,scope=${{ inputs.image }},mode=max
166-
target: goreleaser${{ github.event.pull_request.head.repo.full_name == github.repository && '-prebuilt' || '' }}
169+
target: goreleaser${{ ! inputs.forked-workflow && '-prebuilt' || '' }}
167170
tags: ${{ steps.meta.outputs.tags }}
168171
labels: ${{ steps.meta.outputs.labels }}
169172
annotations: ${{ github.event_name != 'pull_request' && steps.meta.outputs.annotations || '' }}

.github/workflows/build-plus.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ on:
2727
publish-image:
2828
required: false
2929
type: boolean
30+
publish-aws-market-place:
31+
required: false
32+
type: boolean
33+
publish-gcp-market-place:
34+
required: false
35+
type: boolean
36+
publish-nginx-reqistry:
37+
required: false
38+
type: boolean
39+
forked-workflow:
40+
required: false
41+
type: boolean
3042

3143
defaults:
3244
run:
@@ -70,15 +82,15 @@ jobs:
7082
token_format: access_token
7183
workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY }}
7284
service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }}
73-
if: ${{ inputs.publish-image || github.event.pull_request.head.repo.full_name == github.repository }}
85+
if: ${{ inputs.publish-image || ! inputs.forked-workflow }}
7486

7587
- name: Login to GCR
7688
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
7789
with:
7890
registry: gcr.io
7991
username: oauth2accesstoken
8092
password: ${{ steps.auth.outputs.access_token }}
81-
if: ${{ inputs.publish-image || github.event.pull_request.head.repo.full_name == github.repository }}
93+
if: ${{ inputs.publish-image || ! inputs.forked-workflow }}
8294

8395
- name: Authenticate to Google Cloud Marketplace
8496
id: auth-mktpl
@@ -87,28 +99,27 @@ jobs:
8799
token_format: access_token
88100
workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY_MKTPL }}
89101
service_account: ${{ secrets.GCR_SERVICE_ACCOUNT_MKTPL }}
90-
if: github.ref_type == 'tag' && ! contains(inputs.target, 'aws')
102+
if: ${{ inputs.publish-gcp-market-place }}
91103

92104
- name: Login to GCR for Marketplace
93105
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
94106
with:
95107
registry: gcr.io
96108
username: oauth2accesstoken
97109
password: ${{ steps.auth-mktpl.outputs.access_token }}
98-
if: github.ref_type == 'tag' && ! contains(inputs.target, 'aws')
110+
if: ${{ inputs.publish-gcp-market-place }}
99111

100112
- name: Configure AWS Credentials
101113
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
102114
with:
103115
aws-region: us-east-1
104116
role-to-assume: ${{ secrets.AWS_ROLE_MARKETPLACE }}
105-
if: github.ref_type == 'tag' && contains(inputs.target, 'aws')
106-
117+
if: ${{ inputs.publish-aws-market-place }}
107118
- name: Login to ECR
108119
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
109120
with:
110121
registry: 709825985650.dkr.ecr.us-east-1.amazonaws.com
111-
if: github.ref_type == 'tag' && contains(inputs.target, 'aws')
122+
if: ${{ inputs.publish-aws-market-place }}
112123

113124
- name: Get Id Token
114125
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -117,25 +128,25 @@ jobs:
117128
script: |
118129
let id_token = await core.getIDToken()
119130
core.setOutput('id_token', id_token)
120-
if: ${{ inputs.publish-image }}
131+
if: ${{ inputs.publish-nginx-reqistry }}
121132

122133
- name: Login to NGINX Registry
123134
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
124135
with:
125136
registry: docker-mgmt.nginx.com
126137
username: ${{ steps.idtoken.outputs.id_token }}
127138
password: ${{ github.actor }}
128-
if: ${{ inputs.publish-image }}
139+
if: ${{ inputs.publish-nginx-reqistry }}
129140

130141
- name: Docker meta
131142
id: meta
132143
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
133144
with:
134145
images: |
135146
name=gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}/nginx-plus-ingress
136-
name=gcr.io/f5-7626-networks-public/nginxinc/nginx-plus-ingress${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }},enable=${{ github.ref_type == 'tag' && ! contains(inputs.target, 'aws') && ! contains(inputs.image, 'alpine') && ! contains(inputs.image, 'ubi') }}
137-
name=docker-mgmt.nginx.com/nginx-ic${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}/nginx-plus-ingress,enable=${{ github.ref_type != 'pull_request' && ! startsWith(github.ref, 'refs/heads/release-') && ! contains(inputs.target, 'aws') }}
138-
name=709825985650.dkr.ecr.us-east-1.amazonaws.com/nginx/nginx-plus-ingress${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }},enable=${{ github.ref_type == 'tag' && contains(inputs.target, 'aws') }}
147+
name=gcr.io/f5-7626-networks-public/nginxinc/nginx-plus-ingress${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }},enable=${{ inputs.publish-gcp-market-place && ! contains(inputs.target, 'aws') && ! contains(inputs.image, 'alpine') && ! contains(inputs.image, 'ubi') }}
148+
name=docker-mgmt.nginx.com/nginx-ic${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}/nginx-plus-ingress,enable=${{ inputs.publish-nginx-reqistry && ! contains(inputs.target, 'aws') }}
149+
name=709825985650.dkr.ecr.us-east-1.amazonaws.com/nginx/nginx-plus-ingress${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }},enable=${{ inputs.publish-aws-market-place && contains(inputs.target, 'aws') }}
139150
flavor: |
140151
suffix=${{ contains(inputs.image, 'ubi') && '-ubi' || '' }}${{ contains(inputs.image, 'alpine') && '-alpine' || '' }}${{ contains(inputs.target, 'aws') && '-mktpl' || '' }}${{ contains(inputs.image, 'fips') && '-fips' || ''}},onlatest=true
141152
latest=${{ contains(inputs.target, 'aws') && 'false' || 'auto' }}
@@ -165,7 +176,7 @@ jobs:
165176
context: "."
166177
cache-from: type=gha,scope=${{ inputs.image }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }}
167178
cache-to: type=gha,scope=${{ inputs.image }}${{ contains(inputs.nap_modules, 'dos') && '-dos' || '' }}${{ contains(inputs.nap_modules, 'waf') && '-nap' || '' }},mode=max
168-
target: ${{ inputs.target }}${{ github.event.pull_request.head.repo.full_name == github.repository && '-prebuilt' || '' }}
179+
target: ${{ inputs.target }}${{ ! inputs.forked-workflow && '-prebuilt' || '' }}
169180
tags: ${{ steps.meta.outputs.tags }}
170181
labels: ${{ steps.meta.outputs.labels }}
171182
annotations: ${{ inputs.publish-image && steps.meta.outputs.annotations || '' }}
@@ -203,7 +214,7 @@ jobs:
203214
echo "version=$version" >> $GITHUB_OUTPUT
204215
echo "product_code=AWS${nap}_PRODUCT_ID" >> $GITHUB_OUTPUT
205216
echo "registry=${aws_registry}" >> $GITHUB_OUTPUT
206-
if: github.ref_type == 'tag' && contains(inputs.target, 'aws')
217+
if: ${{ inputs.publish-aws-market-place }}
207218

208219
- name: Publish to AWS Marketplace
209220
uses: nginxinc/aws-marketplace-publish@be512a7ae9666098bc4429a1afa27a11be6a3995 # v1.0.3
@@ -220,7 +231,7 @@ jobs:
220231
This container requires Kubernetes and can be deployed to EKS.
221232
Review the installation instructions https://docs.nginx.com/nginx-ingress-controller/installation/ and utilize the deployment resources available https://github.com/nginxinc/kubernetes-ingress/tree/master/deployments
222233
Use this image instead of building your own.
223-
if: ${{ github.ref_type == 'tag' && contains(inputs.target, 'aws') }}
234+
if: ${{ inputs.publish-aws-market-place }}
224235

225236
- name: Extract image name for Trivy
226237
id: trivy-tag

0 commit comments

Comments
 (0)
0