Skip to content

Commit 6900754

Browse files
committed
chore: 🤖 Put build in base path only for repo's staging environment
1 parent b7bb3e2 commit 6900754

File tree

4 files changed

+26
-45
lines changed

4 files changed

+26
-45
lines changed

.changeset/silent-ads-remain.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleek-platform/dashboard": patch
3+
---
4+
5+
Put build in base path only for repo's staging environment

.github/workflows/fleek-deploy-common.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Setup fleek.config.json
6767
run: |
6868
DIST="out"
69-
BUILD="pnpm run build"
69+
BUILD="pnpm run build && .scripts/put_build_in_base_path"
7070
7171
.scripts/setup-fleek-config \
7272
"$FLEEK_SLUG" \

.scripts/build_static_site

+1-14
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,17 @@ source .scripts/test_runner_vars
55

66
outputDir="out"
77
outputBakDir="$outputDir.bak"
8-
outputWithBaseDir="$outputDir/$NEXT_PUBLIC_DASHBOARD_BASE_PATH"
98
indexForRedirectBaseDir="$outputDir/index.html"
109

1110
echo "👷 Build Static site..."
1211

1312
echo "🤖 Run next build..."
1413

15-
if ! next build; then
14+
if ! pnpm exec next build; then
1615
echo "👹 Oops! Nextjs build failed"
1716
exit 1
1817
fi
1918

20-
if [[ ! -z "$NEXT_PUBLIC_DASHBOARD_BASE_PATH" ]]; then
21-
mv "$outputDir" "$outputBakDir"
22-
mkdir -p "$outputWithBaseDir"
23-
24-
if ! cp -r "$outputBakDir"/* "$outputWithBaseDir"; then
25-
echo "👹 Oops! Failed to copy $outputDir to $outputWithBaseDir for some reason..."
26-
exit 1
27-
fi
28-
29-
echo "<html><head><script>window.location.href=\"$NEXT_PUBLIC_DASHBOARD_BASE_PATH\";</script></head></html>" > "$indexForRedirectBaseDir"
30-
fi
31-
3219
echo "🤖 Generate sitemap..."
3320
if ! pnpm run generate:sitemap; then
3421
echo "👹 Oops! Sitemap generator failure"

.scripts/put_build_in_base_path

+19-30
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
#!/bin/bash
22

3-
set -e
3+
echo "👷 Put build in base path (if required)..."
44

5-
if [[ -z "$1" ]]; then
6-
echo "👹 Oops! Missing arguments required for base path NEXT_PUBLIC_BASE_PATH"
7-
exit 1
8-
fi
9-
10-
NEXT_PUBLIC_BASE_PATH="$1"
11-
OUTPUT_DIR="out"
12-
TEMP_DIR="$OUTPUT_DIR.bak"
13-
DEST_DIR="$OUTPUT_DIR/$NEXT_PUBLIC_BASE_PATH"
5+
if [[ -z "$NEXT_PUBLIC_DASHBOARD_BASE_PATH" && -z "$CI" ]]; then
6+
echo "🦖 Skipping build static files due to be running outside CI. The dev server should suggest the address with base path for you!"
147

15-
if [[ ! -d "$OUTPUT_DIR" ]]; then
16-
echo "👹 Oops! The output dir $OUT_DIR doesn not exist"
17-
18-
exit 1
8+
exit 0
199
fi
2010

21-
mv "$OUTPUT_DIR" "$TEMP_DIR" || exit 1
22-
echo "✅ Moved $OUTPUT_DIR to $TEMP_DIR"
23-
24-
mkdir -p "$DEST_DIR" || exit 1
25-
echo "✅ Created $DEST_DIR"
11+
if [[ -n "$NEXT_PUBLIC_DASHBOARD_BASE_PATH" && "$NEXT_PUBLIC_DASHBOARD_BASE_PATH" != '/' ]]; then
12+
echo "🤖 Must copy files to base path $NEXT_PUBLIC_DASHBOARD_BASE_PATH..."
13+
14+
mv "$outputDir" "$outputBakDir"
15+
mkdir -p "$outputWithBaseDir"
2616

27-
cp -r "$TEMP_DIR"/* "$DEST_DIR"
28-
echo "✅ Moved files from $TEMP_DIR to $DEST_DIR"
17+
if ! cp -r "$outputBakDir"/* "$outputWithBaseDir"; then
18+
echo "👹 Oops! Failed to copy $outputDir to $outputWithBaseDir for some reason..."
19+
exit 1
20+
else
21+
echo "✅ Copied output files to $outputWithBaseDir"
22+
fi
2923

30-
rm -rf "$TEMP_DIR" || exit 1
31-
echo "✅ Removed $TEMP_DIR"
32-
33-
if [[ -d "$DEST_DIR" && "$(ls -A $DEST_DIR)" ]]; then
34-
echo "✅ Created $DEST_DIR"
35-
else
36-
echo "👹 Oops! Failed to create $DEST_DIR for some reason..."
37-
38-
exit 1
24+
echo "<html><head><script>window.location.href=\"$NEXT_PUBLIC_DASHBOARD_BASE_PATH\";</script></head></html>" > "$indexForRedirectBaseDir"
3925
fi
26+
27+
echo
28+
echo "👍 Put build in base path completed!"

0 commit comments

Comments
 (0)