forked from opendatahub-io/odh-gitops
-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (88 loc) · 3.56 KB
/
Copy pathhelm-sync.yml
File metadata and controls
99 lines (88 loc) · 3.56 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
name: Helm Sync CI
on:
workflow_dispatch:
push:
branches:
- '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-[3].[0-9]-ea.[0-9]' # e.g. rhoai-3.4-ea.1, rhoai-3.5-ea.2
- 'rhoai-[3].[0-9][0-9]-ea.[0-9]' # e.g. rhoai-3.10-ea.3
paths:
- 'charts/rhai-on-openshift-chart/**'
- 'charts/rhai-on-xks-chart/**'
permissions:
contents: read
# Ensure only one sync runs per branch at a time. When multiple pushes
# happen in quick succession to the same branch, concurrent runs could
# race to commit to the target repo, causing push conflicts or lost writes.
# cancel-in-progress is false so that an in-flight sync is never aborted
# mid-commit — subsequent runs queue and wait their turn instead.
concurrency:
group: helm-sync-${{ github.ref_name }}
cancel-in-progress: false
env:
GITHUB_ORG: red-hat-data-services
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Generate github-app token
id: app-token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.RHOAI_DEVOPS_APP_ID }}
private_key: ${{ secrets.RHOAI_DEVOPS_APP_PRIVATE_KEY }}
- name: Checkout source repo
uses: actions/checkout@v4
with:
repository: ${{ env.GITHUB_ORG }}/odh-gitops
path: source_repo
ref: ${{ github.ref_name }} # Use the same branch name as in the event
token: ${{ steps.app-token.outputs.token }}
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: ${{ env.GITHUB_ORG }}/RHOAI-Build-Config
path: target_repo
ref: ${{ github.ref_name }} # Use the same branch name as in the event
token: ${{ steps.app-token.outputs.token }}
- name: Sync Helm Files
run: |
for chart in rhai-on-openshift-chart rhai-on-xks-chart; do
if [ ! -d "source_repo/charts/${chart}" ]; then
echo "::error::${chart} directory not found in the source repo"
exit 1
fi
echo "Updating helm files for ${chart}"
# Recreate the chart dir so nothing removed in source can linger
rm -rf "target_repo/to-be-processed/helm/${chart}"
mkdir -p "target_repo/to-be-processed/helm/${chart}"
rsync -a \
--exclude '/test/' \
--exclude '/scripts/' \
--exclude 'api-docs.md' \
"source_repo/charts/${chart}/" \
"target_repo/to-be-processed/helm/${chart}/"
done
- name: Check for helm files changes
id: helm-change-check
run: |
cd target_repo
# Stage adds, edits, and deletions (including empty-file removals).
git add -A to-be-processed/helm/
if git diff --staged --quiet; then
echo "helm_changes=empty" >> $GITHUB_OUTPUT
else
echo "helm_changes=present" >> $GITHUB_OUTPUT
fi
- name: Commit and push the changes to release branch
uses: actions-js/push@v1.5
if: ${{ steps.helm-change-check.outputs.helm_changes == 'present' }}
with:
github_token: ${{ steps.app-token.outputs.token }}
branch: ${{ github.ref_name }}
message: "Sync helm chart from odh-gitops@${{ github.sha }}"
repository: ${{ env.GITHUB_ORG }}/RHOAI-Build-Config
directory: target_repo
author_name: Openshift-AI DevOps
author_email: openshift-ai-devops@redhat.com