Repository navigation
Expand file tree
/
Copy pathdeploy_docs.sh
More file actions
executable file
·115 lines (98 loc) · 3.58 KB
/
Copy pathdeploy_docs.sh
File metadata and controls
executable file
·115 lines (98 loc) · 3.58 KB
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
#!/usr/bin/env bash
set -e
set -o pipefail
# === CONFIGURATION ===
# Resolve paths relative to this script's directory so later `cd` doesn't break them
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOCS_DIR="$SCRIPT_DIR/../stepdance_docs/html" # Doxygen HTML output directory (generated)
SOURCE_DOCS_DIR="$SCRIPT_DIR/doc" # Raw source markdown + images to publish alongside HTML
LIB_DIR="$SCRIPT_DIR/lib" # Library source code to zip
TARGET_REPO="git@github.com:pixelmaid/stepdance_docs.git" # CHANGE THIS to your target repository
TARGET_BRANCH="main"
SOURCE_BRANCH="main"
DOXYGEN_CONFIG="doxygen/stepdance_config"
# === ENSURE CLEAN WORKING TREE ===
if [ -n "$(git status --porcelain)" ]; then
echo "Please commit or stash your changes before deploying."
exit 1
fi
# === BUILD DOXYGEN ===
echo "Building Doxygen documentation..."
doxygen "$DOXYGEN_CONFIG"
if [ ! -d "$DOCS_DIR" ]; then
echo "Doxygen output directory not found: $DOCS_DIR"
exit 1
fi
# === CREATE STEPDANCE.ZIP FROM LIB FOLDER ===
echo "Creating Stepdance.zip from lib folder..."
if [ -d "$LIB_DIR" ]; then
# Create a temporary directory and copy lib folder as "Stepdance"
TEMP_LIB_DIR=$(mktemp -d)
cp -R "$LIB_DIR" "$TEMP_LIB_DIR/Stepdance"
# Create zip from the renamed folder in temp directory
cd "$TEMP_LIB_DIR"
ZIP_FILE="$TEMP_LIB_DIR/Stepdance.zip"
zip -r "$ZIP_FILE" Stepdance -x "*.git*" -x "*__pycache__*" -x "*.DS_Store"
cd "$SCRIPT_DIR"
echo "Stepdance.zip created successfully"
else
echo "Library directory not found: $LIB_DIR"
exit 1
fi
# === STORE CURRENT BRANCH AND COMMIT HASH ===
current_branch=$(git rev-parse --abbrev-ref HEAD)
commit_hash=$(git rev-parse --short HEAD)
if [ "$current_branch" != "$SOURCE_BRANCH" ]; then
echo "You are on '$current_branch', not '$SOURCE_BRANCH'. Proceeding anyway..."
fi
# === CREATE TEMP DIRECTORY FOR TARGET REPO ===
echo "Cloning target repository..."
TEMP_DIR=$(mktemp -d)
git clone "$TARGET_REPO" "$TEMP_DIR"
cd "$TEMP_DIR"
# === CHECKOUT OR CREATE TARGET BRANCH ===
if git show-ref --verify --quiet refs/remotes/origin/$TARGET_BRANCH; then
git checkout $TARGET_BRANCH
else
echo "Creating new $TARGET_BRANCH branch..."
git checkout --orphan $TARGET_BRANCH
git reset --hard
fi
# === CLEAN AND COPY NEW DOCS ===
echo "🧹 Cleaning old files..."
rm -rf ./*
echo "Copying new documentation..."
# 1. Generated HTML site contents into repo root
cp -R "$DOCS_DIR"/. .
# 2. Raw source documentation (markdown + images) into a separate folder to allow downstream editing/reference.
# Using 'source_doc' to avoid collisions with any Doxygen output directories.
if [ -d "$SOURCE_DOCS_DIR" ]; then
mkdir -p source_doc
cp -R "$SOURCE_DOCS_DIR"/. source_doc/
else
echo "Source documentation directory not found: $SOURCE_DOCS_DIR (skipping copy)"
fi
# 3. Copy Stepdance.zip library file to repo root
if [ -f "$ZIP_FILE" ]; then
cp "$ZIP_FILE" .
echo "Copied Stepdance.zip to documentation repository"
else
echo "Stepdance.zip not found: $ZIP_FILE (skipping copy)"
fi
# === COMMIT AND PUSH DOCS ===
git add --all
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "Update Doxygen docs (HTML + source markdown + Stepdance.zip) for commit $commit_hash"
git push origin $TARGET_BRANCH
echo "Documentation successfully deployed to '$TARGET_REPO' ($TARGET_BRANCH branch)!"
fi
# === CLEANUP ===
cd -
rm -rf "$TEMP_DIR"
# Clean up temporary library zip directory
if [ -n "$TEMP_LIB_DIR" ] && [ -d "$TEMP_LIB_DIR" ]; then
rm -rf "$TEMP_LIB_DIR"
fi
echo "🧹 Cleaned up temporary directories."