-
Notifications
You must be signed in to change notification settings - Fork 39
287 lines (246 loc) · 9.33 KB
/
sync-pipelineruns.yml
File metadata and controls
287 lines (246 loc) · 9.33 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: Sync Pipelineruns
run-name: Sync Pipelineruns
on:
push:
branches:
- 'main'
- 'rhoai-[23].[0-9]' # e.g. rhoai-2.1, rhoai-3.1, rhoai-3.4
- 'rhoai-[23].[0-9][0-9]' # e.g. rhoai-2.10, rhoai-3.10, rhoai-3.22
- 'rhoai-[23].[0-9]-ea.[0-9]' # e.g. rhoai-2.4-ea.1, rhoai-3.4-ea.1, rhoai-3.5-ea.2
- 'rhoai-[23].[0-9][0-9]-ea.[0-9]' # e.g. rhoai-2.10-ea.1, rhoai-3.10-ea.3
# Only trigger if changes are made inside pipelineruns/
paths:
- 'pipelineruns/**'
workflow_dispatch:
inputs:
dry_run:
type: boolean
description: 'Dry Run (No changes are committed)'
required: true
default: false
repository:
type: choice
description: Select repository for syncing pipelineruns
options:
- all
- NeMo-Guardrails
- ai-gateway-payload-processing
- argo-workflows
- caikit-nlp
- caikit-tgis-serving
- codeflare-operator
- data-science-pipelines
- data-science-pipelines-operator
- distributed-workloads
- eval-hub
- feast
- fms-guardrails-orchestrator
- guardrails-detectors
- ilab-on-ocp
- kserve
- kserve-autogluon-server
- kube-auth-proxy
- kubeflow
- kuberay
- kueue
- llama-stack-k8s-operator
- llama-stack-provider-trustyai-garak
- llm-d-inference-scheduler
- llm-d-kv-cache
- lm-evaluation-harness
- maas-billing
- ml-metadata
- mlflow
- model-metadata-collection
- model-registry
- model-registry-operator
- modelmesh
- modelmesh-runtime-adapter
- modelmesh-serving
- must-gather
- notebooks
- odh-cli
- odh-dashboard
- odh-model-controller
- pipelines-components
- rest-proxy
- rhods-operator
- training-operator
- trustyai-explainability
- trustyai-service-operator
- vllm
- vllm-cpu
- vllm-gaudi
- vllm-orchestrator-gateway
- vllm-rocm
env:
PIPELINERUNS_DIR: "pipelineruns"
SYNC_CONFIG_FILE: "sync-config.yaml"
GITHUB_ORG: "red-hat-data-services"
jobs:
setup:
if: github.event_name == 'workflow_dispatch' || !contains(github.event.head_commit.message, 'skip-sync')
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.config }}
steps:
- name: Checkout code - ${{ github.ref_name }}
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Checkout code - main
uses: actions/checkout@v3
with:
ref: main
path: main
- name: Print Debug Info
run: |
ls -R
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: '3.10.13'
- uses: dorny/paths-filter@v3
if: github.event_name == 'push'
id: filter
with:
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
# Paths will be escaped and space-delimited.
# Output is usable as command-line argument list in Linux shell
list-files: shell
# Detect changes against the most recent commit on the same branch before the push
base: ${{ github.ref }}
# Only filters added or modified files.
filters: |
pipelineruns:
- added|modified: 'pipelineruns/**/.tekton/*.yaml'
- added|modified: 'pipelineruns/**/.tekton/*.yml'
readme:
- modified: 'pipelineruns/README.md.in'
- name: Generate ${{ env.SYNC_CONFIG_FILE }}
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ steps.filter.outputs.readme }}" == "true" ]]; then
# Install Dependencies
python -m pip install --upgrade pip
pip install ruyaml
# copy script to root and remove main clone
cp main/script/generate_pipelinerun_sync_config.py generate_pipelinerun_sync_config.py
rm -rf main
ls -lart
python generate_pipelinerun_sync_config.py --pipelinerun-dir "${{ env.PIPELINERUNS_DIR }}" --output ${{ env.SYNC_CONFIG_FILE }} --github-org ${{ env.GITHUB_ORG }}
else
echo "${{ steps.filter.outputs.pipelineruns_files }}"
files="${{ steps.filter.outputs.pipelineruns_files }}"
seen=""
for path in $files; do
# Extract the repository name from the path
repo=$(cut -d'/' -f2 <<< "$path")
# If this repository hasn't been seen before, add it to the YAML output
if [[ ! " $seen " =~ " $repo " ]]; then
echo " - repo: red-hat-data-services/$repo" >> ${{ env.SYNC_CONFIG_FILE }}
seen+=" $repo"
fi
done
fi
cat ${{ env.SYNC_CONFIG_FILE }}
- name: Generate Matrix Config
id: matrix
run: |
config=$(yq -o json ${{ env.SYNC_CONFIG_FILE }} | jq -c '.')
if ([[ "${{ github.event_name }}" == "workflow_dispatch" ]] && [[ "${{ github.event.inputs.repository }}" != "all" ]])
then
config=$(echo $config | jq -c 'map(select(.["repo"] == "${{ env.GITHUB_ORG }}/${{ github.event.inputs.repository }}"))')
fi
echo "config=${config}"
length=$(echo $config | jq '. | length')
echo "$length repo(s) will be syned by this workflow"
if [[ $length -eq 0 ]]
then
echo "No valid repos available for the sync"
exit 1
fi
echo "$config" | jq .
echo "config=$config" >> $GITHUB_OUTPUT
sync:
needs: [setup]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: configure git committer string
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
path: source
- name: Checkout ${{ matrix.config.repo }}
uses: actions/checkout@v3
with:
repository: ${{ matrix.config.repo }}
token: ${{ steps.app-token.outputs.token }}
ref: ${{ github.ref_name }}
path: target
- name: Print Debug Info
run: |
set -x
ls -lart
ls -lart source/${{ env.PIPELINERUNS_DIR }}
ls -lart target
set +x
- name: Sync Pipelineruns
run: |
export branch=${{ github.ref_name }}
export repo_name=$(basename "${{ matrix.config.repo }}")
echo "repo_name=$repo_name"
echo "branch=$branch"
envsubst < source/${{ env.PIPELINERUNS_DIR }}/README.md.in > source/${{ env.PIPELINERUNS_DIR }}/README.md
[ -d target/.tekton ] || mkdir -p target/.tekton
cp -rf "source/${{ env.PIPELINERUNS_DIR }}/${repo_name}/.tekton/"* "target/.tekton"
cp "source/${{ env.PIPELINERUNS_DIR }}/README.md" "target/.tekton/README.md"
- name: Commit Changes
run: |
cd source
konflux_central_commit=$(git rev-parse --short HEAD)
cd ../target
git config --global color.ui always
set -x
ls -lart
git status
git add -f .tekton
git diff --staged
set +x
# Check if there are any changes to commit
if git diff --staged --quiet; then
echo "Pipelineruns are already in sync. No changes to commit."
else
JOB_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
git commit -m "sync pipelineruns with konflux-central - ${konflux_central_commit}" -m "Triggered by: ${JOB_URL}"
fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.dry_run }}" == "true" ]]; then
echo "'dry_run' input is true. Skipping push."
else
git push origin ${{ github.ref_name }}
fi
# - name: Slack Notification
# if: ${{ failure() }}
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_MESSAGE: ':red-warning: Renovate Synchronization Failed for repo: ${{ matrix.config.repo }}!'
# SLACK_WEBHOOK: ${{ secrets.RHOAI_DEVOPS_SLACK_WEBHOOK }}