Skip to content

Commit

Permalink
Chore/fix gh pages deployments (#1096)
Browse files Browse the repository at this point in the history
* fix: fixes ci to fetch all branches and fixes the sdk-copy.sh script

* fix: fixes sdk_copy

* fix: fixes sdk_copy to include sdk-react

* fix: fixes the deploy script to include existing folders
  • Loading branch information
christopherferreira9 authored Oct 25, 2024
1 parent 9efe8f9 commit cfcbde1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Fetch all branches
run: git fetch --all

- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand Down
10 changes: 7 additions & 3 deletions packages/examples/react-demo/sdk-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ SDK_WORKSPACE_DIR="$( pwd; )";
COMM_LAYER_DIR="$SDK_WORKSPACE_DIR/packages/sdk-communication-layer"
SDK_DIR="$SDK_WORKSPACE_DIR/packages/sdk"
SDK_REACT_DIR="$SDK_WORKSPACE_DIR/packages/sdk-react"
SDK_REACT_UI_DIR="$SDK_WORKSPACE_DIR/packages/sdk-react-ui"
SDK_INSTALL_MODAL_WEB_DIR="$SDK_WORKSPACE_DIR/packages/sdk-install-modal-web"

DAPP_DIR="$SDK_WORKSPACE_DIR/packages/examples/nextjs-demo"
DAPP_DIR="$SDK_WORKSPACE_DIR/packages/examples/react-demo"

echo "SDK_DIR: $SDK_DIR"
echo "COMM_LAYER_DIR: $COMM_LAYER_DIR"
echo "DAPP_DIR: $DAPP_DIR"
echo "SDK_REACT_DIR: $SDK_REACT_DIR"
echo "SDK_REACT_UI_DIR: $SDK_REACT_UI_DIR"
echo "SDK_INSTALL_MODAL_WEB_DIR: $SDK_INSTALL_MODAL_WEB_DIR"

echo "########### START REPLACING SDK_COMMUNICATION_LAYER #########"

cd $DAPP_DIR
echo "Hack Metamask sdk && sdk-communication-layer packages..."
## hack to debug to latest unpublished version of the sdk
rm -rf node_modules/@metamask/sdk-communication-layer/dist node_modules/@metamask/sdk/dist node_modules/@metamask/sdk-react/dist node_modules/@metamask/sdk-react-ui/dist
rm -rf node_modules/@metamask/sdk-communication-layer/dist node_modules/@metamask/sdk/dist node_modules/@metamask/sdk-react/dist
cp -rf $COMM_LAYER_DIR/dist node_modules/@metamask/sdk-communication-layer/dist
cp -rf $COMM_LAYER_DIR/package.json node_modules/@metamask/sdk-communication-layer/package.json

cp -rf $SDK_DIR/dist node_modules/@metamask/sdk/dist
cp -rf $SDK_DIR/package.json node_modules/@metamask/sdk/package.json

cp -rf $SDK_REACT_DIR/dist node_modules/@metamask/sdk-react/dist
cp -rf $SDK_REACT_DIR/package.json node_modules/@metamask/sdk-react/package.json

cp -rf $SDK_INSTALL_MODAL_WEB_DIR/dist node_modules/@metamask/sdk-install-modal-web/dist
cp -rf $SDK_INSTALL_MODAL_WEB_DIR/package.json node_modules/@metamask/sdk-install-modal-web/package.json

Expand Down
8 changes: 2 additions & 6 deletions scripts/build-static-dapps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ update_index_html() {

# Create an index.html file with links to all deployment folders
create_index_html() {
local existing_folders=$1
local existing_folders="$1"
echo "<!DOCTYPE html>
<html lang=\"en\">
<head>
Expand Down Expand Up @@ -199,16 +199,12 @@ update_index_html "$deployment_dir/packages/examples" $deployment_folder

# Fetch the existing folders on the "gh-pages" branch and keep them as a list
existing_folders=$(git ls-tree -d --name-only origin/gh-pages)
# Check if the deployment directory is already in the existing folders list
if ! echo "$existing_folders" | grep -q "^$deployment_folder$"; then
existing_folders="$existing_folders"$'\n'"$deployment_folder"
fi

echo "Existing folders on gh-pages branch:"
echo "$existing_folders"

# Update root index.html to point to the latest deployment
echo "Updating root index.html"
create_index_html $existing_folders
create_index_html "$existing_folders"

echo "Deployment process completed! You can check it out here: https://metamask.github.io/metamask-sdk/$deployment_folder"

0 comments on commit cfcbde1

Please sign in to comment.