Skip to content

Commit

Permalink
Push edge Helm Chart to OCI registries
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Feb 22, 2023
1 parent ce9c5fe commit ab24480
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 126 deletions.
76 changes: 19 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ defaults:
run:
shell: bash

env:
HELM_CHART_DIR: deployments/helm-chart
GIT_NAME: NGINX Kubernetes Team
GIT_MAIL: [email protected]

concurrency:
group: ${{ github.ref_name }}-ci
cancel-in-progress: true
Expand Down Expand Up @@ -342,62 +337,29 @@ jobs:
path: ${{ github.workspace }}/tests/${{ steps.smoke-tests.outputs.test-results-name }}.html
if: always()

package-helm:
name: Package Helm Chart
runs-on: ubuntu-22.04
needs: unit-tests
outputs:
version: ${{ steps.var.outputs.helm_version }}
type: ${{ steps.var.outputs.helm_type }}
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout Repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Output Variables
id: var
run: |
if ${{ startsWith(github.ref, 'refs/tags/') }}; then
helm_version="$(helm show chart ${{ env.HELM_CHART_DIR }} | grep 'version:' | cut -d ' ' -f 2)"
helm_type="stable"
else
helm_version="0.0.0-edge"
helm_type="edge"
fi
echo "helm_version=$helm_version" >> $GITHUB_OUTPUT
echo "helm_type=$helm_type" >> $GITHUB_OUTPUT
- name: Lint
run: helm lint ${{ env.HELM_CHART_DIR }}
- name: Package
run: helm package --version ${{ steps.var.outputs.helm_version }} ${{ env.HELM_CHART_DIR }}
- name: Upload Chart
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: helm-chart
path: ${{ github.workspace }}/nginx-ingress-${{ steps.var.outputs.helm_version }}.tgz

release-helm:
name: Release Helm Chart
publish-helm:
name: Package and Publish Helm Chart
runs-on: ubuntu-22.04
needs: package-helm
needs: helm-tests
if: ${{ github.event_name == 'push' }}
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
repository: nginxinc/helm-charts
fetch-depth: 1
token: ${{ secrets.NGINX_PAT }}
- name: Remove previous Chart
run: rm -f ${{ github.workspace }}/${{ needs.package-helm.outputs.type }}/nginx-ingress-${{ needs.package-helm.outputs.version }}.tgz
- name: Retrieve latest Helm Chart
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: helm-chart
path: ${{ github.workspace }}/${{ needs.package-helm.outputs.type }}
- name: Push Helm Chart
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Package
id: package
run: |
output=$(helm package ${{ ! startsWith(github.ref, 'refs/tags/') && '--app-version edge --version 0.0.0-edge' || '' }} deployments/helm-chart)
echo "path=$(basename -- $(echo $output | cut -d: -f2))" >> $GITHUB_OUTPUT
- name: Push to ghcr.io
run: |
helm repo index ${{ needs.package-helm.outputs.type }} --url https://helm.nginx.com/${{ needs.package-helm.outputs.type }}
git add -A
git -c user.name='${{ env.GIT_NAME }}' -c user.email='${{ env.GIT_MAIL }}' \
commit -m "NGINX Ingress Controller - Release ${{ needs.package-helm.outputs.type }} ${{ needs.package-helm.outputs.version }}"
git push -u origin master
helm push ${{ steps.package.outputs.path }} oci://ghcr.io/nginxinc/charts
helm push ${{ steps.package.outputs.path }} oci://registry-1.docker.io/nginxcharts
9 changes: 9 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ jobs:
- uses: reviewdog/action-actionlint@b6feb003955cad286985c42e7047f4567a798f3f # v1.36.0
with:
actionlint_flags: -shellcheck ""

chart-lint:
name: Chart Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Lint chart
run: helm lint deployments/helm-chart
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ We publish Ingress Controller releases on GitHub. See our [releases page](https:

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.

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.
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.

To use the Ingress Controller, you need to have access to:
* An Ingress Controller image.
Expand Down
Loading

0 comments on commit ab24480

Please sign in to comment.