-
Notifications
You must be signed in to change notification settings - Fork 61
Add Github Action workflow for updating DW Components Release matrix info to confluence #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 2 commits into
project-codeflare:main
from
Srihari1192:RHOAIENG-16512
Mar 20, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
.github/workflows/update-release-matrix-to-confluence.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Update Release Matrix to Confluence | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
rhoai-release-version: | ||
description: 'RHOAI Release Version' | ||
required: true | ||
kueue-version: | ||
description: 'Kueue Version' | ||
required: true | ||
codeflare-sdk-version: | ||
description: 'CodeFlare SDK Version' | ||
required: true | ||
codeflare-operator-version: | ||
description: 'CodeFlare operator Version' | ||
required: true | ||
kuberay-version: | ||
description: 'Tested KubeRay version' | ||
required: true | ||
appwrapper-version: | ||
description: 'Tested appwrapper version' | ||
required: true | ||
Bobbins228 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jobs: | ||
update-confluence: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Release info Parameters | ||
run: | | ||
echo "RHOAI_RELEASE_VERSION=${{ github.event.inputs.rhoai-release-version }}" >> $GITHUB_ENV | ||
echo "KUEUE_VERSION=${{ github.event.inputs.kueue-version }}" >> $GITHUB_ENV | ||
echo "CODEFLARE_SDK_VERSION=${{ github.event.inputs.codeflare-sdk-version }}" >> $GITHUB_ENV | ||
echo "CODEFLARE_OPERATOR_VERSION=${{ github.event.inputs.codeflare-operator-version }}" >> $GITHUB_ENV | ||
echo "KUBERAY_VERSION=${{ github.event.inputs.kuberay-version }}" >> $GITHUB_ENV | ||
echo "APPWRAPPER_VERSION=${{ github.event.inputs.appwrapper-version }}" >> $GITHUB_ENV | ||
|
||
- name: Fetch and Update Existing Release Matrix Page Content | ||
run: | | ||
echo "Fetching Release Matrix Confluence Page..." | ||
response=$(curl -H "Authorization: Bearer ${{ secrets.CONFLUENCE_API_TOKEN }}" \ | ||
"${{ secrets.CONFLUENCE_BASE_URL }}/rest/api/content?title=${{ secrets.PAGE_TITLE }}&spaceKey=${{ secrets.SPACE_KEY }}&expand=body.storage,version") | ||
|
||
echo "$response" | jq '.' > page_data.json | ||
echo "Raw API Response: $response" | ||
|
||
PAGE_VERSION=$(jq '.results[0].version.number' page_data.json) | ||
|
||
if [[ -z "$PAGE_VERSION" || "$PAGE_VERSION" == "null" ]]; then | ||
echo "Error: Could not retrieve current page version." | ||
exit 1 | ||
fi | ||
echo "PAGE_VERSION=$PAGE_VERSION" >> $GITHUB_ENV | ||
|
||
EXISTING_CONTENT=$(jq -r '.results[0].body.storage.value' page_data.json) | ||
|
||
echo "Existing Release Matrix Page Content: $EXISTING_CONTENT" | ||
|
||
if [[ -z "$EXISTING_CONTENT" || "$EXISTING_CONTENT" == "null" ]]; then | ||
echo "Error: Could not retrieve existing page content." | ||
exit 1 | ||
fi | ||
|
||
# Convert newlines to a placeholder to handle multi-line processing | ||
PLACEHOLDER="__NL__" | ||
MODIFIED_CONTENT=$(echo "$EXISTING_CONTENT" | tr '\n' "$PLACEHOLDER") | ||
|
||
# Update the page content with release info also check and update if the release version already exists in the table | ||
if echo "$MODIFIED_CONTENT" | grep -q "<tr[^>]*><td>$RHOAI_RELEASE_VERSION</td>"; then | ||
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|") | ||
else | ||
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>" | ||
UPDATED_PAGE_CONTENT=$(echo "$MODIFIED_CONTENT" | sed "s|</tbody>|$UPDATED_ROW</tbody>|") | ||
fi | ||
|
||
# Correct JSON encoding without double escaping | ||
UPDATED_PAGE_CONTENT=$(echo "$UPDATED_PAGE_CONTENT" | sed 's/_$//') # Remove trailing underscores | ||
UPDATED_PAGE_CONTENT=$(jq -n --arg content "$UPDATED_PAGE_CONTENT" '$content' | tr -d '\r') | ||
# Store as output | ||
echo "UPDATED_PAGE_CONTENT=$UPDATED_PAGE_CONTENT" >> "$GITHUB_ENV" | ||
|
||
- name: Publish updated page content to confluence | ||
run: | | ||
|
||
NEW_VERSION=$(( PAGE_VERSION + 1 )) | ||
|
||
if [[ -n "$UPDATED_PAGE_CONTENT" && "$UPDATED_PAGE_CONTENT" != "null" ]]; then | ||
echo "Updating Confluence Page using PUT request..." | ||
HTTP_RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X PUT "${{ secrets.CONFLUENCE_BASE_URL }}/rest/api/content/${{ secrets.CONFLUENCE_PAGE_ID }}" \ | ||
-H "Authorization: Bearer ${{ secrets.CONFLUENCE_API_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-d "{ | ||
\"id\": \"${{ secrets.CONFLUENCE_PAGE_ID }}\", | ||
\"type\": \"page\", | ||
\"title\": \"Distributed Workloads Release Details\", | ||
\"space\": { \"key\": \"${{ secrets.SPACE_KEY }}\" }, | ||
\"body\": { | ||
\"storage\": { | ||
\"value\": $UPDATED_PAGE_CONTENT, | ||
\"representation\": \"storage\" | ||
} | ||
}, | ||
\"version\": { | ||
\"number\": $NEW_VERSION | ||
} | ||
}") | ||
if [[ "$HTTP_RESPONSE" == "200" || "$HTTP_RESPONSE" == "201" ]]; then | ||
echo "Successfully updated Confluence Page with release version details !" | ||
echo "Response from Confluence:" | ||
cat response.json | ||
else | ||
echo "Error: Failed to update Confluence page. HTTP Response Code: $HTTP_RESPONSE" | ||
exit 1 | ||
fi | ||
else | ||
echo "Error: UPDATED_PAGE_CONTENT is null or empty." | ||
exit 1 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.