forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 28
89 lines (79 loc) · 3.22 KB
/
bundle-sync.yml
File metadata and controls
89 lines (79 loc) · 3.22 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
name: Bundle 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
permissions:
contents: read
packages: write
id-token: write
env:
GITHUB_ORG: red-hat-data-services
GITHUB_RKA_ORG: rhoai-rhtap
jobs:
sync:
if: ${{ github.ref_name != 'main' }}
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@v3
with:
repository: ${{ env.GITHUB_ORG }}/rhods-operator
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@v3
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: Generate bundle files
run: |
cd source_repo
ODH_PLATFORM_TYPE=rhoai make bundle
- name: Sync Bundle Files
run: |
mkdir -p target_repo/to-be-processed/bundle
echo "Updating bundle related files"
rm -rf target_repo/to-be-processed/bundle/*
if [ -d source_repo/rhoai-bundle ]; then
cp -r source_repo/rhoai-bundle/* target_repo/to-be-processed/bundle
else
cp -r source_repo/bundle/* target_repo/to-be-processed/bundle
fi
sed -i -e "s|image: quay.io/opendatahub/opendatahub-operator:latest.*|image: REPLACE_IMAGE:latest|g" target_repo/to-be-processed/bundle/manifests/rhods-operator.clusterserviceversion.yaml
# echo "Updating Dockerfile"
# cp source_repo/Dockerfiles/bundle.Dockerfile target_repo/to-be-processed/bundle/Dockerfile
- name: Check for bundle changes
id: bundle-change-check
run: |
cd target_repo
git add to-be-processed/bundle
if [ -z "$(git diff --staged | grep -P '^[-+]' | grep -v createdAt | grep -v -P '^(\+\+\+|---)')" ]; then
echo "bundle_changes=empty" >> $GITHUB_OUTPUT
else
echo "bundle_changes=present" >> $GITHUB_OUTPUT
fi
- name: Commit and push the changes to release branch
uses: actions-js/push@master
if: ${{ steps.bundle-change-check.outputs.bundle_changes == 'present' }}
with:
github_token: ${{ steps.app-token.outputs.token }}
branch: ${{ github.ref_name }}
message: "Sync changes from source repo"
repository: ${{ env.GITHUB_ORG }}/RHOAI-Build-Config
directory: target_repo
author_name: Openshift-AI DevOps
author_email: openshift-ai-devops@redhat.com