Skip to content

Commit 2fd5846

Browse files
committed
Added scaleway storage deploy scripts
1 parent 62c7a90 commit 2fd5846

File tree

3 files changed

+375
-0
lines changed

3 files changed

+375
-0
lines changed

deploy-scaleway-v11.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Deploy Avalonia Docs to Scaleway Object Storage
5+
# Bucket: v11.docs.avaloniaui.net (fr-par)
6+
# Website: https://v11.docs.avaloniaui.net.s3-website.fr-par.scw.cloud
7+
8+
BUCKET="v11.docs.avaloniaui.net"
9+
RCLONE_REMOTE="scaleway:${BUCKET}"
10+
BUILD_DIR="./build"
11+
WEBSITE_URL="https://${BUCKET}.s3-website.fr-par.scw.cloud"
12+
13+
SKIP_BUILD=false
14+
VERIFY_ONLY=false
15+
16+
usage() {
17+
cat <<EOF
18+
Usage: $(basename "$0") [OPTIONS]
19+
20+
Deploy Avalonia docs to Scaleway Object Storage.
21+
22+
Options:
23+
--skip-build Skip npm ci and build, upload existing build/ directory
24+
--verify-only Only verify the deployment (no build or upload)
25+
--help Show this help message
26+
27+
EOF
28+
exit 0
29+
}
30+
31+
while [[ $# -gt 0 ]]; do
32+
case "$1" in
33+
--skip-build) SKIP_BUILD=true; shift ;;
34+
--verify-only) VERIFY_ONLY=true; shift ;;
35+
--help) usage ;;
36+
*) echo "Unknown option: $1"; usage ;;
37+
esac
38+
done
39+
40+
log() { echo "==> $*"; }
41+
err() { echo "ERROR: $*" >&2; exit 1; }
42+
43+
# --- Preflight checks ---
44+
45+
preflight() {
46+
log "Running preflight checks"
47+
48+
command -v rclone >/dev/null 2>&1 || err "rclone is not installed. Run: brew install rclone"
49+
50+
# Verify rclone can reach Scaleway
51+
if ! rclone lsd scaleway: >/dev/null 2>&1; then
52+
err "Cannot connect to Scaleway via rclone. Run: scw object config install type=rclone region=fr-par"
53+
fi
54+
55+
log "Preflight checks passed"
56+
}
57+
58+
# --- Build ---
59+
60+
build() {
61+
if $SKIP_BUILD; then
62+
log "Skipping build (--skip-build)"
63+
else
64+
log "Installing dependencies"
65+
npm ci
66+
67+
log "Building Docusaurus site"
68+
npm run build || true # redirect plugin may fail; build output is still valid
69+
fi
70+
71+
[[ -f "${BUILD_DIR}/index.html" ]] || err "Build directory missing or empty. Run without --skip-build."
72+
log "Build directory OK ($(du -sh "$BUILD_DIR" | cut -f1) total)"
73+
}
74+
75+
# --- Upload ---
76+
77+
upload() {
78+
log "Uploading hashed assets (immutable cache)"
79+
rclone sync "${BUILD_DIR}/assets/" "${RCLONE_REMOTE}/assets/" \
80+
--header-upload "Cache-Control: public, max-age=31536000, immutable" \
81+
--s3-acl public-read \
82+
--progress
83+
84+
log "Uploading remaining files (short cache)"
85+
rclone sync "${BUILD_DIR}/" "${RCLONE_REMOTE}/" \
86+
--exclude "assets/**" \
87+
--header-upload "Cache-Control: public, max-age=300, s-maxage=3600" \
88+
--s3-acl public-read \
89+
--progress
90+
91+
log "Upload complete"
92+
}
93+
94+
# --- Verify ---
95+
96+
verify() {
97+
log "Verifying deployment at ${WEBSITE_URL}"
98+
99+
local status
100+
status=$(curl -s -o /dev/null -w "%{http_code}" "${WEBSITE_URL}")
101+
102+
if [[ "$status" == "200" ]]; then
103+
log "Verification passed (HTTP ${status})"
104+
else
105+
echo "WARNING: Website returned HTTP ${status}"
106+
echo "If static website hosting is not yet enabled, configure it in the Scaleway console:"
107+
echo " https://console.scaleway.com/object-storage/buckets"
108+
echo "${BUCKET} → Bucket settings → Enable static website hosting"
109+
echo " → Index: index.html, Error: 404.html"
110+
exit 1
111+
fi
112+
}
113+
114+
# --- Main ---
115+
116+
preflight
117+
118+
if $VERIFY_ONLY; then
119+
verify
120+
exit 0
121+
fi
122+
123+
build
124+
upload
125+
verify

deploy-scaleway-v12.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Deploy Avalonia Docs to Scaleway Object Storage
5+
# Bucket: v12.docs.avaloniaui.net (fr-par)
6+
# Website: https://v12.docs.avaloniaui.net.s3-website.fr-par.scw.cloud
7+
8+
BUCKET="v12.docs.avaloniaui.net"
9+
RCLONE_REMOTE="scaleway:${BUCKET}"
10+
BUILD_DIR="./build"
11+
WEBSITE_URL="https://${BUCKET}.s3-website.fr-par.scw.cloud"
12+
13+
SKIP_BUILD=false
14+
VERIFY_ONLY=false
15+
16+
usage() {
17+
cat <<EOF
18+
Usage: $(basename "$0") [OPTIONS]
19+
20+
Deploy Avalonia docs to Scaleway Object Storage.
21+
22+
Options:
23+
--skip-build Skip npm ci and build, upload existing build/ directory
24+
--verify-only Only verify the deployment (no build or upload)
25+
--help Show this help message
26+
27+
EOF
28+
exit 0
29+
}
30+
31+
while [[ $# -gt 0 ]]; do
32+
case "$1" in
33+
--skip-build) SKIP_BUILD=true; shift ;;
34+
--verify-only) VERIFY_ONLY=true; shift ;;
35+
--help) usage ;;
36+
*) echo "Unknown option: $1"; usage ;;
37+
esac
38+
done
39+
40+
log() { echo "==> $*"; }
41+
err() { echo "ERROR: $*" >&2; exit 1; }
42+
43+
# --- Preflight checks ---
44+
45+
preflight() {
46+
log "Running preflight checks"
47+
48+
command -v rclone >/dev/null 2>&1 || err "rclone is not installed. Run: brew install rclone"
49+
50+
# Verify rclone can reach Scaleway
51+
if ! rclone lsd scaleway: >/dev/null 2>&1; then
52+
err "Cannot connect to Scaleway via rclone. Run: scw object config install type=rclone region=fr-par"
53+
fi
54+
55+
log "Preflight checks passed"
56+
}
57+
58+
# --- Build ---
59+
60+
build() {
61+
if $SKIP_BUILD; then
62+
log "Skipping build (--skip-build)"
63+
else
64+
log "Installing dependencies"
65+
npm ci
66+
67+
log "Building Docusaurus site"
68+
npm run build || true # redirect plugin may fail; build output is still valid
69+
fi
70+
71+
[[ -f "${BUILD_DIR}/index.html" ]] || err "Build directory missing or empty. Run without --skip-build."
72+
log "Build directory OK ($(du -sh "$BUILD_DIR" | cut -f1) total)"
73+
}
74+
75+
# --- Upload ---
76+
77+
upload() {
78+
log "Uploading hashed assets (immutable cache)"
79+
rclone sync "${BUILD_DIR}/assets/" "${RCLONE_REMOTE}/assets/" \
80+
--header-upload "Cache-Control: public, max-age=31536000, immutable" \
81+
--s3-acl public-read \
82+
--progress
83+
84+
log "Uploading remaining files (short cache)"
85+
rclone sync "${BUILD_DIR}/" "${RCLONE_REMOTE}/" \
86+
--exclude "assets/**" \
87+
--header-upload "Cache-Control: public, max-age=300, s-maxage=3600" \
88+
--s3-acl public-read \
89+
--progress
90+
91+
log "Upload complete"
92+
}
93+
94+
# --- Verify ---
95+
96+
verify() {
97+
log "Verifying deployment at ${WEBSITE_URL}"
98+
99+
local status
100+
status=$(curl -s -o /dev/null -w "%{http_code}" "${WEBSITE_URL}")
101+
102+
if [[ "$status" == "200" ]]; then
103+
log "Verification passed (HTTP ${status})"
104+
else
105+
echo "WARNING: Website returned HTTP ${status}"
106+
echo "If static website hosting is not yet enabled, configure it in the Scaleway console:"
107+
echo " https://console.scaleway.com/object-storage/buckets"
108+
echo "${BUCKET} → Bucket settings → Enable static website hosting"
109+
echo " → Index: index.html, Error: 404.html"
110+
exit 1
111+
fi
112+
}
113+
114+
# --- Main ---
115+
116+
preflight
117+
118+
if $VERIFY_ONLY; then
119+
verify
120+
exit 0
121+
fi
122+
123+
build
124+
upload
125+
verify

deploy-scaleway.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Deploy Avalonia Docs to Scaleway Object Storage
5+
# Bucket: docs.avaloniaui.net (fr-par)
6+
# Website: https://docs.avaloniaui.net.s3-website.fr-par.scw.cloud
7+
8+
BUCKET="docs.avaloniaui.net"
9+
RCLONE_REMOTE="scaleway:${BUCKET}"
10+
BUILD_DIR="./build"
11+
WEBSITE_URL="https://${BUCKET}.s3-website.fr-par.scw.cloud"
12+
13+
SKIP_BUILD=false
14+
VERIFY_ONLY=false
15+
16+
usage() {
17+
cat <<EOF
18+
Usage: $(basename "$0") [OPTIONS]
19+
20+
Deploy Avalonia docs to Scaleway Object Storage.
21+
22+
Options:
23+
--skip-build Skip npm ci and build, upload existing build/ directory
24+
--verify-only Only verify the deployment (no build or upload)
25+
--help Show this help message
26+
27+
EOF
28+
exit 0
29+
}
30+
31+
while [[ $# -gt 0 ]]; do
32+
case "$1" in
33+
--skip-build) SKIP_BUILD=true; shift ;;
34+
--verify-only) VERIFY_ONLY=true; shift ;;
35+
--help) usage ;;
36+
*) echo "Unknown option: $1"; usage ;;
37+
esac
38+
done
39+
40+
log() { echo "==> $*"; }
41+
err() { echo "ERROR: $*" >&2; exit 1; }
42+
43+
# --- Preflight checks ---
44+
45+
preflight() {
46+
log "Running preflight checks"
47+
48+
command -v rclone >/dev/null 2>&1 || err "rclone is not installed. Run: brew install rclone"
49+
50+
# Verify rclone can reach Scaleway
51+
if ! rclone lsd scaleway: >/dev/null 2>&1; then
52+
err "Cannot connect to Scaleway via rclone. Run: scw object config install type=rclone region=fr-par"
53+
fi
54+
55+
log "Preflight checks passed"
56+
}
57+
58+
# --- Build ---
59+
60+
build() {
61+
if $SKIP_BUILD; then
62+
log "Skipping build (--skip-build)"
63+
else
64+
log "Installing dependencies"
65+
npm ci
66+
67+
log "Building Docusaurus site"
68+
npm run build || true # redirect plugin may fail; build output is still valid
69+
fi
70+
71+
[[ -f "${BUILD_DIR}/index.html" ]] || err "Build directory missing or empty. Run without --skip-build."
72+
log "Build directory OK ($(du -sh "$BUILD_DIR" | cut -f1) total)"
73+
}
74+
75+
# --- Upload ---
76+
77+
upload() {
78+
log "Uploading hashed assets (immutable cache)"
79+
rclone sync "${BUILD_DIR}/assets/" "${RCLONE_REMOTE}/assets/" \
80+
--header-upload "Cache-Control: public, max-age=31536000, immutable" \
81+
--s3-acl public-read \
82+
--progress
83+
84+
log "Uploading remaining files (short cache)"
85+
rclone sync "${BUILD_DIR}/" "${RCLONE_REMOTE}/" \
86+
--exclude "assets/**" \
87+
--header-upload "Cache-Control: public, max-age=300, s-maxage=3600" \
88+
--s3-acl public-read \
89+
--progress
90+
91+
log "Upload complete"
92+
}
93+
94+
# --- Verify ---
95+
96+
verify() {
97+
log "Verifying deployment at ${WEBSITE_URL}"
98+
99+
local status
100+
status=$(curl -s -o /dev/null -w "%{http_code}" "${WEBSITE_URL}")
101+
102+
if [[ "$status" == "200" ]]; then
103+
log "Verification passed (HTTP ${status})"
104+
else
105+
echo "WARNING: Website returned HTTP ${status}"
106+
echo "If static website hosting is not yet enabled, configure it in the Scaleway console:"
107+
echo " https://console.scaleway.com/object-storage/buckets"
108+
echo "${BUCKET} → Bucket settings → Enable static website hosting"
109+
echo " → Index: index.html, Error: 404.html"
110+
exit 1
111+
fi
112+
}
113+
114+
# --- Main ---
115+
116+
preflight
117+
118+
if $VERIFY_ONLY; then
119+
verify
120+
exit 0
121+
fi
122+
123+
build
124+
upload
125+
verify

0 commit comments

Comments
 (0)