forked from kubeflow/kubeflow
-
Notifications
You must be signed in to change notification settings - Fork 37
149 lines (133 loc) · 5.2 KB
/
kubeflow-release.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
---
name: Kubeflow Release Pipeline
on:
workflow_dispatch:
inputs:
release-type:
description: "Select the type of action to perform"
required: true
default: "Sync"
type: choice
options:
- Sync
- Release
env:
CREATE_NEW_RELEASE: ${{ inputs.release-type == 'Release' }}
REPO_OWNER: opendatahub-io
REPO_NAME: kubeflow
BRANCH_NAME: v1.9-branch
jobs:
# 1. Sync changes to opendatahub:v1.9-branch from opendatahub:main
sync-main-to-release-branch:
uses: opendatahub-io/kubeflow/.github/workflows/sync-branches.yaml@main
with:
source: "main"
target: "v1.9-branch"
# 2. Poll for images to be available on quay.io the readiness of the images usually takes ~10 mins
wait-images-are-ready-on-quay:
needs: sync-main-to-release-branch
runs-on: ubuntu-latest
outputs:
images_ready: ${{ steps.check-images.outputs.images_ready }}
steps:
- name: Poll for images availability
id: check-images
run: |
# Install required tools
sudo apt-get update
sudo apt-get install -y skopeo jq curl
# Get the latest Git hash from the target branch
PAYLOAD=$(curl --silent -H 'Accept: application/vnd.github.v4.raw' https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/commits?sha=$BRANCH_NAME&per_page=1)
GIT_HASH=$(echo "$PAYLOAD" | jq -r '.[0].sha' | cut -c 1-7)
echo "GIT_HASH=$GIT_HASH"
# Images to check
IMAGES=(
"quay.io/opendatahub/kubeflow-notebook-controller:1.9-${GIT_HASH}"
"quay.io/opendatahub/odh-notebook-controller:1.9-${GIT_HASH}"
)
# Sleep for 5 minutes before starting polling
echo "Sleeping for 5 minutes before starting polling..."
sleep 300
# Poll for image readiness total timeout=20m
MAX_ATTEMPTS=13
SLEEP_DURATION=90
for image in "${IMAGES[@]}"; do
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do
echo "Checking availability of $image (Attempt $i/$MAX_ATTEMPTS)..."
if skopeo inspect docker://$image &>/dev/null; then
echo "$image is available!"
break
fi
if [[ $i -eq $MAX_ATTEMPTS ]]; then
echo "Timed out waiting for $image to become available."
exit 1
fi
sleep $SLEEP_DURATION
done
done
echo "images_ready=true" >> $GITHUB_ENV
echo "images_ready=true" >> $GITHUB_OUTPUT
- name: Images are ready
if: ${{ env.images_ready == 'true' }}
run: echo "All images are ready. Proceeding to the next step."
# 3. Once Images are availble then updates the notebook controllers’ image tags
update-release-images:
needs: wait-images-are-ready-on-quay
if: ${{ needs.wait-images-are-ready-on-quay.outputs.images_ready == 'true' }}
uses: opendatahub-io/kubeflow/.github/workflows/notebook-controller-images-updater.yaml@main
with:
branch-name: "v1.9-branch"
organization: "opendatahub-io"
generate-pr: "true"
secrets:
GH_TOKEN: ${{ secrets.GHA_SECRET_PAT }}
# 4. Check PR merged status
check-pr-merged:
needs: update-release-images
runs-on: ubuntu-latest
outputs:
pr_merged: ${{ steps.check.outputs.pr_merged }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Check if the PR is merged
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# PR to look for
PR_TITLE="[GHA-${{ github.run_id }}]"
# Fetch matching PRs
PR_NUMBER=$(gh pr list --repo "$REPO_OWNER/$REPO_NAME" --state all --search "$PR_TITLE" --json number,title | jq -r '.[0].number')
echo "PR number: $PR_NUMBER"
if [ -z "$PR_NUMBER" ]; then
echo "No matching PR found."
exit 1
fi
# Polling loop to wait for the PR to be merged total timeout=5h
MAX_ATTEMPTS=30
SLEEP_DURATION=600
for (( i=1; i<=MAX_ATTEMPTS; i++ )); do
echo "Checking if PR #$PR_NUMBER is merged (Attempt $i/$MAX_ATTEMPTS)..."
PR_STATE=$(gh pr view --repo "$REPO_OWNER/$REPO_NAME" $PR_NUMBER --json mergedAt --jq '.mergedAt')
if [ "$PR_STATE" = "null" ] || [ -z "$PR_STATE" ]; then
echo "PR #$PR_NUMBER is not merged yet. Waiting..."
sleep $SLEEP_DURATION
else
echo "PR #$PR_NUMBER is merged!"
echo "pr_merged=true" >> $GITHUB_ENV
echo "pr_merged=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "Timed out waiting for PR #$PR_NUMBER to be merged."
echo "pr_merged=false" >> $GITHUB_ENV
echo "pr_merged=false" >> $GITHUB_OUTPUT
exit 1
# 5. Create a release
create-release:
needs: [update-release-images, check-pr-merged]
if: ${{ needs.check-pr-merged.outputs.pr_merged == 'true' && inputs.release-type == 'Release' }}
uses: opendatahub-io/kubeflow/.github/workflows/create-release.yaml@main
with:
target_branch: "v1.9-branch"