-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (123 loc) · 5.89 KB
/
Copy pathupdate-rhdh-version.yaml
File metadata and controls
147 lines (123 loc) · 5.89 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Update RHDH Version
on:
schedule:
- cron: "0 9 * * 1" # Weekly on Monday at 9am UTC (after plugin sync)
workflow_dispatch:
inputs:
target_version:
description: "Specific version to update to (leave empty for latest)"
required: false
jobs:
check-update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Determine Helm repo based on branch
id: config
run: |
BRANCH="${GITHUB_REF_NAME}"
if [[ "$BRANCH" == "main" ]]; then
# Community chart for main branch
echo "repo_name=rhdh-chart" >> $GITHUB_OUTPUT
echo "repo_url=https://redhat-developer.github.io/rhdh-chart/" >> $GITHUB_OUTPUT
echo "chart_name=backstage" >> $GITHUB_OUTPUT
else
# Official chart for release branches
echo "repo_name=openshift-helm-charts" >> $GITHUB_OUTPUT
echo "repo_url=https://charts.openshift.io" >> $GITHUB_OUTPUT
echo "chart_name=redhat-developer-hub" >> $GITHUB_OUTPUT
fi
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Add Helm repo and get latest version
id: helm
run: |
helm repo add ${{ steps.config.outputs.repo_name }} ${{ steps.config.outputs.repo_url }}
helm repo update
# Get latest version or use specified version
if [[ -n "${{ github.event.inputs.target_version }}" ]]; then
LATEST_VERSION="${{ github.event.inputs.target_version }}"
else
LATEST_VERSION=$(helm search repo ${{ steps.config.outputs.repo_name }}/${{ steps.config.outputs.chart_name }} --versions | awk 'NR==2 {print $2}')
fi
# Get current version from the ACTIVE (uncommented) line
CURRENT_VERSION=$(grep '^HELM_CHART_VERSION=' env_variables.sh | cut -d'=' -f2)
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
if [[ "$CURRENT_VERSION" != "$LATEST_VERSION" ]]; then
echo "needs_update=true" >> $GITHUB_OUTPUT
else
echo "needs_update=false" >> $GITHUB_OUTPUT
fi
- name: Update version
if: steps.helm.outputs.needs_update == 'true'
run: |
# Update the active (uncommented) HELM_CHART_VERSION line
# Update env_variables.sh
sed -i "s/^HELM_CHART_VERSION=.*/HELM_CHART_VERSION=${{ steps.helm.outputs.latest }}/" env_variables.sh
# Update deploy/configmap.yaml
sed -i "s/^ HELM_CHART_VERSION: .*/ HELM_CHART_VERSION: ${{ steps.helm.outputs.latest }}/" deploy/configmap.yaml
echo "Updated HELM_CHART_VERSION from ${{ steps.helm.outputs.current }} to ${{ steps.helm.outputs.latest }}"
- name: Sync dynamic plugins
if: steps.helm.outputs.needs_update == 'true'
run: |
# Sync from the same branch in RHDH (main -> main, release-1.9 -> release-1.9)
BRANCH="${GITHUB_REF_NAME}"
echo "Syncing dynamic-plugins.default.yaml from RHDH branch: $BRANCH"
curl -sfL "https://raw.githubusercontent.com/redhat-developer/rhdh/${BRANCH}/dynamic-plugins.default.yaml" \
-o resources/rhdh/dynamic-plugins.default.yaml || {
echo "ERROR: Could not fetch from branch $BRANCH"
exit 1
}
- name: Generate ConfigMap
if: steps.helm.outputs.needs_update == 'true'
run: |
cat > resources/rhdh/dynamic-plugins-configmap.yaml << 'CONFIGMAP_HEADER'
# AUTO-GENERATED - Do not edit directly
# Source: dynamic-plugins.default.yaml from upstream RHDH
# To regenerate locally: ./scripts/generate-configmap.sh
#
# This ConfigMap is applied to the cluster and consumed by RHDH
# for dynamic plugin configuration.
kind: ConfigMap
apiVersion: v1
metadata:
name: rhdh-dynamic-plugins
labels:
backstage.io/kubernetes-id: developer-hub
data:
dynamic-plugins.yaml: |
CONFIGMAP_HEADER
# Indent the YAML content (6 spaces for ConfigMap data block) and Remove leading spaces only from comment lines before 'plugins:'
awk '
/^[[:space:]]*plugins:/ { found=1 }
!found && /^[[:space:]]*#/ { sub(/^[[:space:]]+/, "") }
{ print " " $0 }
' resources/rhdh/dynamic-plugins.default.yaml >> resources/rhdh/dynamic-plugins-configmap.yaml
echo "Generated ConfigMap at resources/rhdh/dynamic-plugins-configmap.yaml"
- name: Create Pull Request
if: steps.helm.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: update RHDH to version ${{ steps.helm.outputs.latest }}"
title: "[Auto] Update RHDH to ${{ steps.helm.outputs.latest }}"
body: |
## RHDH Version Update
Updates Red Hat Developer Hub from **${{ steps.helm.outputs.current }}** to **${{ steps.helm.outputs.latest }}**
**Chart Source:** `${{ steps.config.outputs.repo_name }}/${{ steps.config.outputs.chart_name }}`
### Changes
- Updated `HELM_CHART_VERSION` in `env_variables.sh`
- Updated `dynamic-plugins.default.yaml` (if available for this version)
- Regenerated `dynamic-plugins-configmap.yaml`
### Review Checklist
- [ ] Review RHDH release notes for breaking changes
- [ ] Check if any scripts need updates for new plugin configurations
- [ ] Test deployment locally
[RHDH Release Notes](https://github.com/redhat-developer/rhdh/releases)
branch: auto/update-rhdh-version
labels: |
automated
dependencies
delete-branch: true