-
Notifications
You must be signed in to change notification settings - Fork 3
/
vercel.sh
41 lines (33 loc) · 1.43 KB
/
vercel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# github submodule repo address without https:// prefix
SUBMODULE_GITHUB=github.com/datalinkhq/subscription-validator
# .gitmodules submodule path
SUBMODULE_PATH=submodules/subscription-validator
# 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="785a46575cf25ce7e3f2d9d7dd59a088e79718d2" #${no_prefix% *} # get rid of the suffix
# set up an empty temporary work directory
rm -rf submodules/*
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 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
mkdir submodules/subscription-validator # create the submodule folder
mv tmp/* submodules/subscription-validator # move the submodule to the submodule path
# clean up
rm -rf tmp # remove the tmp folder