Skip to content

Commit bd9785e

Browse files
authored
Push edge Helm Chart to OCI registries (#3581)
1 parent 96e1fe4 commit bd9785e

File tree

8 files changed

+146
-114
lines changed

8 files changed

+146
-114
lines changed

.github/workflows/build-oss.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747

4848
- name: Docker Buildx
4949
uses: docker/setup-buildx-action@f03ac48505955848960e80bbb68046aa35c7b9e7 # v2.4.1
50+
5051
- name: DockerHub Login
5152
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
5253
with:

.github/workflows/ci.yml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ defaults:
2121
run:
2222
shell: bash
2323

24-
env:
25-
HELM_CHART_DIR: deployments/helm-chart
26-
GIT_NAME: NGINX Kubernetes Team
27-
28-
2924
concurrency:
3025
group: ${{ github.ref_name }}-ci
3126
cancel-in-progress: true
@@ -342,62 +337,67 @@ jobs:
342337
path: ${{ github.workspace }}/tests/${{ steps.smoke-tests.outputs.test-results-name }}.html
343338
if: always()
344339

345-
package-helm:
346-
name: Package Helm Chart
340+
publish-helm:
341+
name: Package and Publish Helm Chart
347342
runs-on: ubuntu-22.04
348-
needs: unit-tests
349-
outputs:
350-
version: ${{ steps.var.outputs.helm_version }}
351-
type: ${{ steps.var.outputs.helm_type }}
343+
needs: helm-tests
352344
if: ${{ github.event_name == 'push' }}
345+
permissions:
346+
contents: read
347+
packages: write
353348
steps:
354349
- name: Checkout Repository
355350
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
356-
- name: Output Variables
357-
id: var
358-
run: |
359-
if ${{ startsWith(github.ref, 'refs/tags/') }}; then
360-
helm_version="$(helm show chart ${{ env.HELM_CHART_DIR }} | grep 'version:' | cut -d ' ' -f 2)"
361-
helm_type="stable"
362-
else
363-
helm_version="0.0.0-edge"
364-
helm_type="edge"
365-
fi
366-
echo "helm_version=$helm_version" >> $GITHUB_OUTPUT
367-
echo "helm_type=$helm_type" >> $GITHUB_OUTPUT
368-
- name: Lint
369-
run: helm lint ${{ env.HELM_CHART_DIR }}
370-
- name: Package
371-
run: helm package --version ${{ steps.var.outputs.helm_version }} ${{ env.HELM_CHART_DIR }}
372-
- name: Upload Chart
373-
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
374351
with:
375-
name: helm-chart
376-
path: ${{ github.workspace }}/nginx-ingress-${{ steps.var.outputs.helm_version }}.tgz
352+
path: kic
353+
354+
- name: Login to GitHub Container Registry
355+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
356+
with:
357+
registry: ghcr.io
358+
username: ${{ github.repository_owner }}
359+
password: ${{ secrets.GITHUB_TOKEN }}
360+
361+
- name: DockerHub Login
362+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
363+
with:
364+
username: ${{ secrets.DOCKER_USERNAME }}
365+
password: ${{ secrets.DOCKER_PASSWORD }}
366+
367+
- name: Package
368+
id: package
369+
run: |
370+
output=$(helm package ${{ ! startsWith(github.ref, 'refs/tags/') && '--app-version edge --version 0.0.0-edge' || '' }} kic/deployments/helm-chart)
371+
echo "path=$(basename -- $(echo $output | cut -d: -f2))" >> $GITHUB_OUTPUT
372+
373+
- name: Push to OCI registries
374+
run: |
375+
helm push ${{ steps.package.outputs.path }} oci://ghcr.io/nginxinc/charts
376+
helm push ${{ steps.package.outputs.path }} oci://registry-1.docker.io/nginxcharts
377377
378-
release-helm:
379-
name: Release Helm Chart
380-
runs-on: ubuntu-22.04
381-
needs: package-helm
382-
if: ${{ github.event_name == 'push' }}
383-
steps:
384378
- name: Checkout Repository
385379
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
386380
with:
387381
repository: nginxinc/helm-charts
388382
fetch-depth: 1
389383
token: ${{ secrets.NGINX_PAT }}
384+
path: helm-charts
385+
386+
- name: Get Chart type
387+
id: package-helm
388+
run: |
389+
echo "type=${{ contains(steps.package.outputs.path, 'edge') && 'edge' || 'stable' }}" >> $GITHUB_OUTPUT
390+
390391
- name: Remove previous Chart
391-
run: rm -f ${{ github.workspace }}/${{ needs.package-helm.outputs.type }}/nginx-ingress-${{ needs.package-helm.outputs.version }}.tgz
392-
- name: Retrieve latest Helm Chart
393-
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
394-
with:
395-
name: helm-chart
396-
path: ${{ github.workspace }}/${{ needs.package-helm.outputs.type }}
397-
- name: Push Helm Chart
392+
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
393+
run: rm -f ${{ github.workspace }}/helm-charts/edge/nginx-ingress-0.0.0-edge.tgz
394+
395+
- name: Push Helm Chart to Helm Charts Repository
398396
run: |
397+
mv ${{ steps.package.outputs.path }} ${{ github.workspace }}/helm-charts/${{ steps.package-helm.outputs.type }}/
398+
cd ${{ github.workspace }}/helm-charts
399399
helm repo index ${{ needs.package-helm.outputs.type }} --url https://helm.nginx.com/${{ needs.package-helm.outputs.type }}
400400
git add -A
401-
git -c user.name='${{ env.GIT_NAME }}' -c user.email='${{ env.GIT_MAIL }}' \
401+
git -c user.name='NGINX Kubernetes Team' -c user.email='[email protected]' \
402402
commit -m "NGINX Ingress Controller - Release ${{ needs.package-helm.outputs.type }} ${{ needs.package-helm.outputs.version }}"
403403
git push -u origin master

.github/workflows/lint.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,12 @@ jobs:
4848
- uses: reviewdog/action-actionlint@b6feb003955cad286985c42e7047f4567a798f3f # v1.36.0
4949
with:
5050
actionlint_flags: -shellcheck ""
51+
52+
chart-lint:
53+
name: Chart Lint
54+
runs-on: ubuntu-22.04
55+
steps:
56+
- name: Checkout Repository
57+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
58+
- name: Lint chart
59+
run: helm lint deployments/helm-chart

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ We publish Ingress Controller releases on GitHub. See our [releases page](https:
5555

5656
The latest stable release is [3.0.2](https://github.com/nginxinc/kubernetes-ingress/releases/tag/v3.0.2). For production use, we recommend that you choose the latest stable release.
5757

58-
The edge version is useful for experimenting with new features that are not yet published in a stable release. To use, choose the *edge* version built from the [latest commit](https://github.com/nginxinc/kubernetes-ingress/commits/main) from the main branch.
58+
The edge version is useful for experimenting with new features that are not yet published in a stable release. To use it, choose the *edge* version built from the [latest commit](https://github.com/nginxinc/kubernetes-ingress/commits/main) from the main branch.
5959

6060
To use the Ingress Controller, you need to have access to:
6161
* An Ingress Controller image.

0 commit comments

Comments
 (0)