-
Notifications
You must be signed in to change notification settings - Fork 23
117 lines (101 loc) · 4.47 KB
/
sync-chart.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Prepare Operator Release
on:
workflow_dispatch:
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
jobs:
sync:
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- 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
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync
id: sync
run: |
current_nic_version=$(yq e '.appVersion' helm-charts/nginx-ingress/Chart.yaml)
echo "Current NIC version: $current_nic_version"
current_operator_version=$(egrep '^VERSION' Makefile | awk '{ print $3 }')
echo "Current Operator version: $current_operator_version"
cd helm-charts/
rm -rf nginx-ingress
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 ../schemas/v${{ inputs.k8s_version || '1.30.0' }} nginx-ingress/v${{ 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 || '2.3.0' }} >> $GITHUB_OUTPUT
- name: Find and Replace NIC version
uses: jacobtomlinson/gha-find-replace@a51bbcd94d000df9ca0fcb54ec8be69aad8374b0 # v3.0.2
with:
find: ${{ steps.sync.outputs.current_nic_version }}
replace: ${{ steps.sync.outputs.new_nic_version }}
regex: false
exclude: .github/**
- name: Find and Replace Operator version
uses: jacobtomlinson/gha-find-replace@a51bbcd94d000df9ca0fcb54ec8be69aad8374b0 # v3.0.2
with:
find: ${{ steps.sync.outputs.current_operator_version }}
replace: ${{ steps.sync.outputs.new_operator_version }}
regex: false
exclude: .github/**
- name: Run Diff
run: |
ls -al helm-charts/nginx-ingress
cat helm-charts/nginx-ingress/values.schema.json
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 }}