Skip to content

WIP: Fix the bash script for GitHub playground uploads #1215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions prepare_public_folder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,36 @@
set -e

# Create the public folder to be published on Pages
rm -rf public
mkdir -p public
# Set an entrypoint to avoid 404 on Pages
echo "<h1>JS SDK Playground</h1>" > public/index.html

# Fetch origin to list the branches below
git fetch --no-tags
git fetch --prune --no-tags

# Loop all the branches and - for each - build the SDK, build the playground-js
# and copy the `dist` folder in the global `public` folder.
for branch_name in $(git for-each-ref --format='%(refname:short)' refs/remotes/origin/); do
# Remove `remote/` from refname
branch=${branch_name/origin\//}
if [[ $branch == "canary" ]]; then
# canary branch is too old!
echo "Skip canary branch"
continue
fi

folder="public/$branch"
echo "\nCreate folder $folder"
mkdir -p $folder
for remote in $( \
git branch -r \
| awk '{print $1}' \
| grep '^origin/' \
| grep -vE '^origin/(HEAD|canary)$' \
); do
branch="${remote#origin/}"

echo "Processing branch: $branch"

echo "Creating public/$branch"
mkdir -p "public/$branch"

echo "Checkout $branch"
git switch -f "$branch"

echo "NPM install and Build SDK for this branch"
# TODO: Build only JS/required sdks
npm ci && npm run build
echo "Build playgrounds"

echo "Building playgrounds for $branch"
{
# VITE_BASE used in internal/playground-js/vite.config.ts
VITE_BASE="/signalwire-js/$branch/" npm run -w=@sw-internal/playground-js build
Expand Down
Loading