Skip to content

Commit 2d55f04

Browse files
committed
refactor: restructure docs into website subdirectory
Reorganize the documentation repository structure to consolidate all documentation files under the website/ directory for better organization and build consistency. Changes include: - Move all docs/ content to website/docs/ - Add .dockerignore to exclude node_modules from Docker context - Update Dockerfile to work with new structure - Remove obsolete version 1.25 - Update import_docs.sh script for new paths - Extract json config from ts files for easier jq updates - Use the 1.28 as the default documentation page - Avoid marking 1.27 as unsupported Signed-off-by: Francesco Canovai <[email protected]>
1 parent 90ea03d commit 2d55f04

File tree

801 files changed

+306
-30035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

801 files changed

+306
-30035
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Build containers
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
58

69
env:
710
REGISTRY: "ghcr.io"

.github/workflows/sync_docs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ jobs:
1616
# CHECKOUT CNPG DOCS REPO
1717
# -----------------------------
1818
- name: Checkout docs repo
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2020
with:
2121
fetch-depth: 0
2222

2323
- name: Setup Node.js
24-
uses: actions/setup-node@v4
24+
uses: actions/setup-node@v6
2525
with:
26-
node-version: 20
2726
cache: 'yarn'
2827

2928
- name: Install dependencies

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
FROM node:lts-trixie-slim
1+
FROM node:lts-alpine
22

3-
RUN apt update && \
4-
apt install -y git && \
5-
git clone https://github.com/cloudnative-pg/docs /website
3+
COPY website /website
64

75
WORKDIR /website
86
RUN yarn

scripts/import_docs.sh

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,50 +98,62 @@ if [[ ! -d "$SOURCE_PATH" ]]; then
9898
exit 1
9999
fi
100100

101-
# Install node modules if missing
102-
if ! command -v yarn >/dev/null 2>&1; then
103-
echo "ERROR: yarn not found. Install Yarn."
101+
if ! command -v jq >/dev/null 2>&1; then
102+
echo "ERROR: jq not found. Install jq for JSON processing."
104103
exit 1
105104
fi
106105

107-
if [[ ! -d "node_modules" ]]; then
108-
echo "node_modules missing: running yarn install"
109-
yarn install --silent
110-
fi
111-
112106
# ===== MAIN BRANCH =====
113107
if [[ "$IS_MAIN" == true ]]; then
114-
echo "Copying imported docs -> ./docs"
115-
mkdir -p ./docs
116-
rsync -av --delete "$SOURCE_PATH/" --exclude "css" ./docs/
117-
108+
echo "Copying imported docs -> ./website/docs"
109+
mkdir -p ./website/docs
110+
rsync -av --delete "$SOURCE_PATH/" --exclude "css" ./website/docs/
118111
echo "Updated ./docs from main — import completed."
119112
exit 0
120113
fi
121-
122114
# ===== VERSION TAG =====
123-
if grep -q "\"${VERSION_DIR}\"" versions.json 2>/dev/null; then
124-
# Import the new version in the correct folder
125-
TARGET_DIRECTORY="./versioned_docs/version-${VERSION_DIR}"
126-
echo "Copying imported docs -> ${TARGET_DIRECTORY}"
127-
rsync -av --delete "$SOURCE_PATH/" --exclude "css" "${TARGET_DIRECTORY}"
128-
else
129-
# Create Docusaurus version
130-
echo "Running: yarn docusaurus docs:version ${VERSION_DIR}"
131-
yarn docusaurus docs:version "${VERSION_DIR}"
115+
VERSIONS_JSON="./website/versions.json"
116+
VERSIONS_CONFIG="./website/versions_config.json"
117+
DOCUSAURUS_CONFIG="./website/docusaurus.config.ts"
118+
TARGET_DIRECTORY="./website/versioned_docs/version-${VERSION_DIR}"
132119

133-
# Import the new version in the correct folder
134-
TARGET_DIRECTORY="./versioned_docs/version-${VERSION_DIR}"
135-
echo "Copying imported docs -> ${TARGET_DIRECTORY}"
136-
rsync -av --delete "$SOURCE_PATH/" --exclude "css" "${TARGET_DIRECTORY}"
120+
echo "Copying imported docs -> ${TARGET_DIRECTORY}"
121+
rsync -av --delete "$SOURCE_PATH/" --exclude "css" "${TARGET_DIRECTORY}"
137122

138-
echo "=== Done: Docusaurus version ${VERSION_DIR} created ==="
123+
# Add the new version to versions.json if not already present
124+
if ! grep -q "\"${VERSION_DIR}\"" versions.json 2>/dev/null; then
125+
# Import the new version in the correct folder
126+
cp "./website/sidebar_config.json" "./website/versioned_sidebars/version-${VERSION_DIR}-sidebars.json"
127+
jq --arg version "$VERSION_DIR" \
128+
'. = [$version] + . | unique' \
129+
"$VERSIONS_JSON" > "${VERSIONS_JSON}.tmp" && \
130+
mv "${VERSIONS_JSON}.tmp" "$VERSIONS_JSON"
139131
fi
140132

141-
# Mark RC as preview
142-
VDIR="versioned_docs/version-${VERSION_DIR}"
133+
# Determine the banner value
143134
if [[ "$IS_RC" == true ]]; then
144-
echo "Marking ${VDIR} as preview (rc)"
145-
echo "preview: true" > "${VDIR}/.preview"
135+
BANNER="unreleased"
136+
else
137+
BANNER="none"
146138
fi
147139

140+
echo "Updating versions_config.json: version ${VERSION_DIR} banner=${BANNER}"
141+
jq --arg version "$VERSION_DIR" --arg banner "$BANNER" \
142+
'.[$version] = {"badge": true, "banner": $banner}' \
143+
"$VERSIONS_CONFIG" > "${VERSIONS_CONFIG}.tmp" && \
144+
mv "${VERSIONS_CONFIG}.tmp" "$VERSIONS_CONFIG"
145+
146+
# Determine if this is the highest version and update docusaurus.config.ts
147+
HIGHEST_VERSION=$(jq -r '.[]' "$VERSIONS_JSON" | sort -V | tail -n1)
148+
149+
if [[ "$VERSION_DIR" == "$HIGHEST_VERSION" ]] && [[ "$IS_RC" == false ]]; then
150+
echo "Version ${VERSION_DIR} is the highest release - updating lastVersion in docusaurus.config.ts"
151+
152+
# Update lastVersion in docusaurus.config.ts
153+
sed -i.bak "s/lastVersion: '[^']*'/lastVersion: '${VERSION_DIR}'/" "$DOCUSAURUS_CONFIG" && \
154+
rm "${DOCUSAURUS_CONFIG}.bak"
155+
156+
echo "Updated lastVersion to ${VERSION_DIR}"
157+
else
158+
echo "Version ${VERSION_DIR} is not the highest release - lastVersion unchanged"
159+
fi

sidebars.ts

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)