Skip to content

Commit 98fe247

Browse files
Add Github Action workflow for updating DW Components Release matrix info to confluence
1 parent b612ce3 commit 98fe247

File tree

2 files changed

+150
-7
lines changed

2 files changed

+150
-7
lines changed

.github/workflows/project-codeflare-release.yml

+29-7
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ on:
3030
description: 'GitHub organization/user containing repositories used for release'
3131
required: true
3232
default: 'project-codeflare'
33-
quay-organization:
34-
description: 'Quay organization used to push the built images to'
35-
required: true
36-
default: 'project-codeflare'
3733
community-operators-prod-organization:
3834
description: 'Owner of target community-operators-prod repository used to open a PR against'
3935
required: true
4036
default: 'redhat-openshift-ecosystem'
37+
rhoai-release-version:
38+
description: "RHOAI Release version for updating Component Release Matrix Versions Info "
39+
required: true
4140

4241
jobs:
4342
release-parameters:
@@ -54,7 +53,6 @@ jobs:
5453
echo "Tested Kueue Version: ${{ github.event.inputs.kueue-version }}"
5554
echo "Is Stable: ${{ github.event.inputs.is-stable }}"
5655
echo "CodeFlare Repository Organization: ${{ github.event.inputs.codeflare-repository-organization }}"
57-
echo "Quay Organization: ${{ github.event.inputs.quay-organization }}"
5856
echo "Community Operators Prod Organization: ${{ github.event.inputs.community-operators-prod-organization }}"
5957
6058
release-codeflare-sdk:
@@ -74,7 +72,7 @@ jobs:
7472
run: |
7573
semver_version="${{ github.event.inputs.codeflare-sdk-version }}"
7674
plain_version="${semver_version:1}"
77-
gh workflow run release.yaml --repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-sdk --ref ${{ github.ref }} --field release-version=${plain_version} --field is-stable=${{ github.event.inputs.is-stable }} --field quay-organization=${{ github.event.inputs.quay-organization }}
75+
gh workflow run release.yaml --repo ${{ github.event.inputs.codeflare-repository-organization }}/codeflare-sdk --ref ${{ github.ref }} --field release-version=${plain_version} --field is-stable=${{ github.event.inputs.is-stable }} --field quay-organization=project-codeflare
7876
env:
7977
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
8078
shell: bash
@@ -107,7 +105,7 @@ jobs:
107105
--field appwrapper-version=${{ github.event.inputs.appwrapper-version }} \
108106
--field kuberay-version=${{ github.event.inputs.kuberay-version }} \
109107
--field kueue-version=${{ github.event.inputs.kueue-version }} \
110-
--field quay-organization=${{ github.event.inputs.quay-organization }} \
108+
--field quay-organization=project-codeflare \
111109
--field community-operators-prod-fork-organization=${{ github.event.inputs.codeflare-repository-organization }} \
112110
--field community-operators-prod-organization=${{ github.event.inputs.community-operators-prod-organization }}
113111
env:
@@ -184,3 +182,27 @@ jobs:
184182
185183
- name: Verify generated file
186184
run: cat config/component_metadata.yaml
185+
186+
Update_release_version_info_to_confluence:
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Checkout Repository
190+
uses: actions/checkout@v4
191+
192+
- name: Trigger and Update Component Release Matrix Versions Info to Confluence
193+
run: |
194+
gh workflow run update-release-matrix-to-confluence.yml --ref ${{ github.ref }} \
195+
--field rhoai-release-version=${{ github.event.inputs.rhoai-release-version }} \
196+
--field kueue-version=${{ github.event.inputs.kueue-version }} \
197+
--field codeflare-sdk-version=${{ github.event.inputs.codeflare-sdk-version }} \
198+
--field codeflare-operator-version=${{ github.event.inputs.operator-version }} \
199+
--field kuberay-version=${{ github.event.inputs.kuberay-version }} \
200+
--field appwrapper-version=${{ github.event.inputs.appwrapper-version }}
201+
202+
# wait for a while for Run to be started
203+
sleep 5
204+
run_id=$(gh run list --workflow update-release-matrix-to-confluence.yml --repo https://github.com/project-codeflare/codeflare-operator --limit 1 --json databaseId --jq .[].databaseId)
205+
gh run watch ${run_id} --repo https://github.com/project-codeflare/codeflare-operator --interval 10 --exit-status
206+
env:
207+
GITHUB_TOKEN: ${{ secrets.CODEFLARE_MACHINE_ACCOUNT_TOKEN }}
208+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Update Release Matrix to Confluence
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
rhoai-release-version:
7+
description: 'RHOAI Release Version'
8+
required: true
9+
kueue-version:
10+
description: 'Kueue Version'
11+
required: true
12+
codeflare-sdk-version:
13+
description: 'CodeFlare SDK Version'
14+
required: true
15+
codeflare-operator-version:
16+
description: 'CodeFlare operator Version'
17+
required: true
18+
kuberay-version:
19+
description: 'Tested KubeRay version'
20+
required: true
21+
appwrapper-version:
22+
description: 'Tested appwrapper version'
23+
required: true
24+
25+
jobs:
26+
update-confluence:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout Repository
30+
uses: actions/checkout@v4
31+
32+
- name: Release info Parameters
33+
run: |
34+
echo "RHOAI_RELEASE_VERSION=${{ github.event.inputs.rhoai-release-version }}" >> $GITHUB_ENV
35+
echo "KUEUE_VERSION=${{ github.event.inputs.kueue-version }}" >> $GITHUB_ENV
36+
echo "CODEFLARE_SDK_VERSION=${{ github.event.inputs.codeflare-sdk-version }}" >> $GITHUB_ENV
37+
echo "CODEFLARE_OPERATOR_VERSION=${{ github.event.inputs.codeflare-operator-version }}" >> $GITHUB_ENV
38+
echo "KUBERAY_VERSION=${{ github.event.inputs.kuberay-version }}" >> $GITHUB_ENV
39+
echo "APPWRAPPER_VERSION=${{ github.event.inputs.appwrapper-version }}" >> $GITHUB_ENV
40+
41+
- name: Fetch and Update Existing Release Matrix Page Content
42+
run: |
43+
echo "Fetching Release Matrix Confluence Page..."
44+
response=$(curl -H "Authorization: Bearer ${{ secrets.CONFLUENCE_API_TOKEN }}" \
45+
"${{ secrets.CONFLUENCE_BASE_URL }}/rest/api/content?title=${{ secrets.PAGE_TITLE }}&spaceKey=${{ secrets.SPACE_KEY }}&expand=body.storage,version")
46+
47+
echo "$response" | jq '.' > page_data.json
48+
echo "Raw API Response: $response"
49+
50+
PAGE_VERSION=$(jq '.results[0].version.number' page_data.json)
51+
52+
if [[ -z "$PAGE_VERSION" || "$PAGE_VERSION" == "null" ]]; then
53+
echo "Error: Could not retrieve current page version."
54+
exit 1
55+
fi
56+
echo "PAGE_VERSION=$PAGE_VERSION" >> $GITHUB_ENV
57+
58+
EXISTING_CONTENT=$(jq -r '.results[0].body.storage.value' page_data.json)
59+
60+
echo "Existing Release Matrix Page Content: $EXISTING_CONTENT"
61+
62+
if [[ -z "$EXISTING_CONTENT" || "$EXISTING_CONTENT" == "null" ]]; then
63+
echo "Error: Could not retrieve existing page content."
64+
exit 1
65+
fi
66+
67+
# Convert newlines to a placeholder to handle multi-line processing
68+
PLACEHOLDER="__NL__"
69+
MODIFIED_CONTENT=$(echo "$EXISTING_CONTENT" | tr '\n' "$PLACEHOLDER")
70+
71+
# Update the page content with release info also check and update if the release version already exists in the table
72+
if echo "$MODIFIED_CONTENT" | grep -q "<tr[^>]*><td>$RHOAI_RELEASE_VERSION</td>"; then
73+
UPDATED_PAGE_CONTENT=$(echo "$MODIFIED_CONTENT" | sed -E "s|(<tr[^>]*><td>$RHOAI_RELEASE_VERSION</td><td>)[^<]+(</td><td>)[^<]+(</td><td>)[^<]+(</td><td>)[^<]+(</td><td>)[^<]+(</td></tr>)|\1$KUEUE_VERSION\2$CODEFLARE_SDK_VERSION\3$CODEFLARE_OPERATOR_VERSION\4$KUBERAY_VERSION\5$APPWRAPPER_VERSION\6|")
74+
else
75+
UPDATED_ROW="<tr class=\"\"><td>$RHOAI_RELEASE_VERSION</td><td>$KUEUE_VERSION</td><td>$CODEFLARE_SDK_VERSION</td><td>$CODEFLARE_OPERATOR_VERSION</td><td>$KUBERAY_VERSION</td><td>$APPWRAPPER_VERSION</td></tr>"
76+
UPDATED_PAGE_CONTENT=$(echo "$MODIFIED_CONTENT" | sed "s|</tbody>|$UPDATED_ROW</tbody>|")
77+
fi
78+
79+
# Correct JSON encoding without double escaping
80+
UPDATED_PAGE_CONTENT=$(echo "$UPDATED_PAGE_CONTENT" | sed 's/_$//') # Remove trailing underscores
81+
UPDATED_PAGE_CONTENT=$(jq -n --arg content "$UPDATED_PAGE_CONTENT" '$content' | tr -d '\r')
82+
# Store as output
83+
echo "UPDATED_PAGE_CONTENT=$UPDATED_PAGE_CONTENT" >> "$GITHUB_ENV"
84+
85+
- name: Publish updated page content to confluence
86+
run: |
87+
88+
NEW_VERSION=$(( PAGE_VERSION + 1 ))
89+
90+
if [[ -n "$UPDATED_PAGE_CONTENT" && "$UPDATED_PAGE_CONTENT" != "null" ]]; then
91+
echo "Updating Confluence Page using PUT request..."
92+
HTTP_RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X PUT "${{ secrets.CONFLUENCE_BASE_URL }}/rest/api/content/${{ secrets.CONFLUENCE_PAGE_ID }}" \
93+
-H "Authorization: Bearer ${{ secrets.CONFLUENCE_API_TOKEN }}" \
94+
-H "Content-Type: application/json" \
95+
-d "{
96+
\"id\": \"${{ secrets.CONFLUENCE_PAGE_ID }}\",
97+
\"type\": \"page\",
98+
\"title\": \"Distributed Workloads Release Details\",
99+
\"space\": { \"key\": \"${{ secrets.SPACE_KEY }}\" },
100+
\"body\": {
101+
\"storage\": {
102+
\"value\": $UPDATED_PAGE_CONTENT,
103+
\"representation\": \"storage\"
104+
}
105+
},
106+
\"version\": {
107+
\"number\": $NEW_VERSION
108+
}
109+
}")
110+
if [[ "$HTTP_RESPONSE" == "200" || "$HTTP_RESPONSE" == "201" ]]; then
111+
echo "Successfully updated Confluence Page with release version details !"
112+
echo "Response from Confluence:"
113+
cat response.json
114+
else
115+
echo "Error: Failed to update Confluence page. HTTP Response Code: $HTTP_RESPONSE"
116+
exit 1
117+
fi
118+
else
119+
echo "Error: UPDATED_PAGE_CONTENT is null or empty."
120+
exit 1
121+
fi

0 commit comments

Comments
 (0)