Skip to content

Commit

Permalink
try it out
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 committed Aug 12, 2024
1 parent e4b545f commit 0b54353
Showing 1 changed file with 44 additions and 17 deletions.
61 changes: 44 additions & 17 deletions .github/workflows/sync-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ on:
inputs:
chart_version:
description: "Chart version"
type: string
required: true
operator_version:
description: "Operator version"
type: string
required: true
k8s_version:
description: "Kubernetes version"
type: string
required: true
dry_run:
description: "Do not commit to a PR"
type: boolean
default: false
push:
branches:
- sync-update

permissions:
contents: read
Expand All @@ -20,9 +33,16 @@ jobs:
contents: write
pull-requests: write
steps:
- name: Checkout
- name: Checkout Operator
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
token: ${{ secrets.NGINX_PAT }}

- name: Checkout Kuberneres json schema
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: nginxinc/kubernetes-json-schema
path: schemas
token: ${{ secrets.NGINX_PAT }}

- name: Setup Helm
Expand All @@ -40,24 +60,25 @@ jobs:
echo "Current Operator version: $current_operator_version"
cd helm-charts/
schema_dir=$(cd nginx-ingress && echo v1.*)
mv nginx-ingress/$schema_dir $schema_dir
rm -rf nginx-ingress
helm pull oci://ghcr.io/nginxinc/charts/nginx-ingress --untar --version ${{ inputs.chart_version }}
helm pull oci://ghcr.io/nginxinc/charts/nginx-ingress --untar --version ${{ inputs.chart_version || '1.3.0' }}
rm -f nginx-ingress/templates/clusterrole.yaml
rm -f nginx-ingress/templates/controller-role.yaml
rm -f nginx-ingress/templates/controller-rolebinding.yaml
sed -i '14s/name: {{ include "nginx-ingress.fullname" . }}/name: nginx-ingress-operator-nginx-ingress-admin/' nginx-ingress/templates/clusterrolebinding.yaml
mv $schema_dir nginx-ingress/
mv ../schemas/${{ inputs.k8s_version || '1.30.0' }} nginx-ingress/${{ inputs.k8s_version || '1.30.0' }}
sed -i -e "s#ref\": \"file.*_def#ref\": \"file://./helm-charts/nginx-ingress/v${{ inputs.k8s_version || '1.30.0' }}/_def#" nginx-ingress/values.schema.json
rm -rf ../schemas
new_nic_version=$(yq e '.appVersion' nginx-ingress/Chart.yaml)
echo "New NIC version: $new_nic_version"
echo current_nic_version=$current_nic_version >> $GITHUB_OUTPUT
echo current_operator_version=$current_operator_version >> $GITHUB_OUTPUT
echo new_nic_version=$new_nic_version >> $GITHUB_OUTPUT
echo new_operator_version=${{ inputs.operator_version }} >> $GITHUB_OUTPUT
echo new_operator_version=${{ inputs.operator_version || '2.3.0' }} >> $GITHUB_OUTPUT
- name: Find and Replace NIC version
uses: jacobtomlinson/gha-find-replace@a51bbcd94d000df9ca0fcb54ec8be69aad8374b0 # v3.0.2
Expand All @@ -73,14 +94,20 @@ jobs:
replace: ${{ steps.sync.outputs.new_operator_version }}
regex: false

- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.NGINX_PAT }}
commit-message: Update NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}
title: Update NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}
branch: feat/update-nic-to-${{ steps.sync.outputs.new_version }}
author: nginx-bot <[email protected]>
body: |
This automated PR updates the NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}.
The Helm Chart was updated to ${{ inputs.chart_version }}.
- name: Run Diff
run: |
git diff
if: ${{ inputs.dry_run || true }}

# - name: Create Pull Request
# uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
# with:
# token: ${{ secrets.NGINX_PAT }}
# commit-message: Update NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}
# title: Update NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}
# branch: feat/update-nic-to-${{ steps.sync.outputs.new_version }}
# author: nginx-bot <[email protected]>
# body: |
# This automated PR updates the NGINX Ingress Controller to ${{ steps.sync.outputs.new_version }}.
# The Helm Chart was updated to ${{ inputs.chart_version }}.
# if: ${{ ! inputs.dry_run || false }}

0 comments on commit 0b54353

Please sign in to comment.