Skip to content

Commit

Permalink
Migrate website to monorepo (calcom#1962)
Browse files Browse the repository at this point in the history
* Adds website as a submodule

* Added website to monorepo

* Adds script to depliy submodules on Vercel

* Updates website

* Updates vercel script

* Sets default branch name as main

* Update website

* Cleanup git logs in Vercel

* Update website

* Update website
  • Loading branch information
zomars authored Feb 23, 2022
1 parent eac2e4e commit 73cdf5d
Show file tree
Hide file tree
Showing 5 changed files with 1,261 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "apps/website"]
path = apps/website
url = [email protected]:calcom/website.git
6 changes: 6 additions & 0 deletions .husky/post-receive
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

echo "Updating submodules recursively"
pwd
git submodule update --init --recursive
1 change: 1 addition & 0 deletions apps/website
Submodule website added at 4bcd19
41 changes: 41 additions & 0 deletions vercel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# github submodule repo address without https:// prefix
SUBMODULE_GITHUB=github.com/calcom/website

# .gitmodules submodule path
SUBMODULE_PATH=apps/website

# github access token is necessary
# add it to Environment Variables on Vercel
if [ "$GITHUB_ACCESS_TOKEN" == "" ]; then
echo "Error: GITHUB_ACCESS_TOKEN is empty"
exit 1
fi

# stop execution on error - don't let it build if something goes wrong
set -e

# get submodule commit
output=`git submodule status --recursive` # get submodule info
no_prefix=${output#*-} # get rid of the prefix
COMMIT=${no_prefix% *} # get rid of the suffix

# set up an empty temporary work directory
rm -rf tmp || true # remove the tmp folder if exists
mkdir tmp # create the tmp folder
cd tmp # go into the tmp folder

# checkout the current submodule commit
git config --global init.defaultBranch main
git config --global advice.detachedHead false
git init # initialise empty repo
git remote add origin https://$GITHUB_ACCESS_TOKEN@$SUBMODULE_GITHUB # add origin of the submodule
git fetch --depth=1 origin $COMMIT # fetch only the required version
git checkout $COMMIT # checkout on the right commit

# move the submodule from tmp to the submodule path
cd .. # go folder up
rm -rf tmp/.git # remove .git
mv tmp/* $SUBMODULE_PATH/ # move the submodule to the submodule path

# clean up
rm -rf tmp # remove the tmp folder
Loading

0 comments on commit 73cdf5d

Please sign in to comment.