forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 16
153 lines (135 loc) · 6.09 KB
/
operator-processor.yaml
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
148
149
150
151
152
153
name: Operator Processor
on:
workflow_dispatch:
push:
branches:
- 'rhoai-2.1[6-9]+'
paths:
- build/operator-nudging.yaml
env:
GITHUB_ORG: red-hat-data-services
GITHUB_RKA_ORG: rhoai-rhtap
permissions:
contents: write
jobs:
operator-processor:
if: ${{ github.ref_name != 'main' && (github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.event.commits[0].author.name == 'konflux-internal-p02[bot]' )) }}
runs-on: ubuntu-latest
steps:
- name: Checkout RBC repo
uses: actions/checkout@v4
with:
repository: ${{ env.GITHUB_ORG }}/RHOAI-Build-Config
ref: ${{ github.ref_name }}
path: RBC
sparse-checkout: |
bundle/bundle-patch.yaml
sparse-checkout-cone-mode: false
- name: Git checkout utils
uses: actions/checkout@v4
with:
repository: ${{ env.GITHUB_RKA_ORG }}/RHOAI-Konflux-Automation
ref: main
path: utils
sparse-checkout: |
utils/operator-processor
sparse-checkout-cone-mode: false
- name: Git checkout utils
uses: actions/checkout@v4
with:
repository: ${{ env.GITHUB_ORG }}/rhods-operator
ref: ${{ github.ref_name }}
path: rhods-operator
sparse-checkout: |
build
prefetched-manifests
.tekton
sparse-checkout-cone-mode: false
- name: Install dependencies
run: |
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
arch="$(uname -m | sed 's/x86_64/amd64/')"
yq_version="v4.44.3"
yq_filename="yq-$yq_version"
echo "-> Downloading yq" >&2
curl -sSfLo "$yq_filename" "https://github.com/mikefarah/yq/releases/download/$yq_version/yq_${os}_${arch}"
chmod +x $yq_filename
ln -s $yq_filename yq
cp $yq_filename /usr/local/bin/yq
pip install -r utils/utils/operator-processor/requirements.txt
- name: Execute Operator Processor
env:
BRANCH: ${{ github.ref_name }}
RHOAI_QUAY_API_TOKEN: ${{ secrets.RHOAI_QUAY_API_TOKEN }}
run: |
RHOAI_VERSION=v${BRANCH/rhoai-/}
COMPONENT_SUFFIX=${RHOAI_VERSION/./-}
ODH_OPERATOR_COMPONENT_NAME=odh-operator-${COMPONENT_SUFFIX}
PUSH_PIPELINE_PATH=rhods-operator/.tekton/${ODH_OPERATOR_COMPONENT_NAME}-push.yaml
PATCH_YAML_PATH=RBC/bundle/bundle-patch.yaml
OPERANDS_MAP_PATH=rhods-operator/build/operands-map.yaml
NUDGING_YAML_PATH=rhods-operator/build/operator-nudging.yaml
MANIFEST_CONFIG_PATH=rhods-operator/build/manifests-config.yaml
python3 utils/utils/operator-processor/operator-processor.py -op process-operator-yamls --patch-yaml-path ${PATCH_YAML_PATH} --operands-map-path ${OPERANDS_MAP_PATH} --nudging-yaml-path ${NUDGING_YAML_PATH} --manifest-config-path ${MANIFEST_CONFIG_PATH} --rhoai-version ${BRANCH} --push-pipeline-yaml-path ${PUSH_PIPELINE_PATH} --push-pipeline-operation enable
echo "----- NUDGING_YAML ------"
cat $NUDGING_YAML_PATH
echo "----- OPERANDS_MAP ------"
cat $OPERANDS_MAP_PATH
echo "----- MANIFEST_CONFIG ------"
cat $MANIFEST_CONFIG_PATH
echo "current dir = $(pwd)"
- name: Fetch all manifests
env:
BRANCH: ${{ github.ref_name }}
run: |
#!/bin/bash
set -e
echo "current dir = $(pwd)"
MANIFEST_CONFIG_PATH=${{ github.workspace }}/rhods-operator/build/manifests-config.yaml
mkdir -p rhods-operator/prefetched-manifests
mkdir -p manifests
cd manifests
while IFS= read -r value;
do
value=${value/- /}
component=$value
if [[ -n $component ]]
then
git_url=$(value="$value" yq '.map[strenv(value)]["git.url"]' ${MANIFEST_CONFIG_PATH})
git_commit=$(value="$value" yq '.map[strenv(value)]["git.commit"]' ${MANIFEST_CONFIG_PATH})
if [[ "$git_commit" == "github.ref_name" ]]; then git_commit=${BRANCH}; echo "changed the value to $BRANCH"; fi
src=$(value="$value" yq '.map[strenv(value)]["src"]' ${MANIFEST_CONFIG_PATH})
dest=$(value="$value" yq '.map[strenv(value)]["dest"]' ${MANIFEST_CONFIG_PATH})
echo "component = $component"
echo "git_url = $git_url"
echo "git_commit = $git_commit"
echo "src = $src"
echo "dest = $dest"
mkdir -p $component
cd $component
git config --global init.defaultBranch ${BRANCH}
git init
git remote add origin $git_url
git config core.sparseCheckout true
git config core.sparseCheckoutCone false
echo "$src" >> .git/info/sparse-checkout
git fetch --depth=1 origin $git_commit
git checkout $git_commit
cd ../
echo "current dir = $(pwd)"
mkdir -p ${{ github.workspace }}/rhods-operator/prefetched-manifests/$dest
cp -r $component/$src/* ${{ github.workspace }}/rhods-operator/prefetched-manifests/$dest
fi
done < <(yq e '.map | keys' ${MANIFEST_CONFIG_PATH} )
cd ${{ github.workspace }}/rhods-operator/prefetched-manifests
tree
- name: Commit and push the changes to release branch
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
message: "Updating the operator repo with latest images and manifests"
repository: ${{ env.GITHUB_ORG }}/rhods-operator
directory: rhods-operator
author_name: Openshift-AI DevOps
author_email: [email protected]