Skip to content

Commit

Permalink
Update the switcher json to order correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Nov 22, 2024
1 parent a27113d commit fc95fab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/docs_build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,21 @@ jobs:
NEW_URL="${BASE_URL}/${version}/"
# Extract the current latest version entry
FIRST_ENTRY=$(jq '.[0]' <<< "${SWITCHER_CONTENT}")
CURRENT_LATEST_ENTRY=$(jq '.[1]' <<< "${SWITCHER_CONTENT}")
# Remove the "name" field from the current latest entry
UPDATED_CURRENT_LATEST_ENTRY=$(jq '.[1] | del(.name)' <<< "$SWITCHER_CONTENT")
# Create the new version entry with the "latest" tag
NEW_ENTRY=$(jq -n --arg version "${version}" --arg url "$NEW_URL" \
'{version: $version, url: $url, name: "v\($version) (latest)"}')
'{version: $version, url: $url, name: "($version) (latest)"}')
UPDATED_SWITCHER_CONTENT=$(jq --argjson new_entry "$NEW_ENTRY" \
--argjson updated_current_latest_entry "$UPDATED_CURRENT_LATEST_ENTRY" \
'.[1] = $updated_current_latest_entry | . += [$new_entry]' <<< "$SWITCHER_CONTENT")
# Combine the entries in the desired order
UPDATED_SWITCHER_CONTENT=$(jq --argjson first_entry "$FIRST_ENTRY" \
--argjson new_entry "$NEW_ENTRY" \
--argjson updated_current_stable_entry "$UPDATED_CURRENT_STABLE_ENTRY" \
'[$first_entry, $new_entry, $updated_current_stable_entry] + .[2:]' <<< "$SWITCHER_CONTENT")
# Write the updated content back to switcher.json
echo "$UPDATED_SWITCHER_CONTENT" > "$SWITCHER_FILE"
Expand Down

0 comments on commit fc95fab

Please sign in to comment.