File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 1212 "test" : " echo \" Error: no test specified\" && exit 1" ,
1313 "daily-schedule" : " node ./schedule/daily-problem.js && node ./schedule/daily-check.js && node ./schedule/check-in.js" ,
1414 "generate" : " node ./static/solution/generate.js && node ./static/users/generate.js" ,
15- "lecture" : " node ./static/lectures/generate.js"
15+ "lecture" : " node ./static/lectures/generate.js" ,
16+ "vercel-install" : " ./vercel-submodule-workaround.sh && yarn --ignore-scripts --production=false"
1617 },
1718 "dependencies" : {
1819 "@koa/cors" : " ^3.1.0" ,
3536 "devDependencies" : {
3637 "nodemon" : " ^1.19.1"
3738 }
38- }
39+ }
Original file line number Diff line number Diff line change 1+ # github submodule repo address without https:// prefix
2+ SUBMODULE_GITHUB=github.com/beeinger/vercel-private-submodule
3+
4+ # .gitmodules submodule path
5+ SUBMODULE_PATH=library
6+
7+ # github access token is necessary
8+ # add it to Environment Variables on Vercel
9+ if [ " $GITHUB_ACCESS_TOKEN " == " " ]; then
10+ echo " Error: GITHUB_ACCESS_TOKEN is empty"
11+ exit 1
12+ fi
13+
14+ # stop execution on error - don't let it build if something goes wrong
15+ set -e
16+
17+ # get submodule commit
18+ output=` git submodule status --recursive` # get submodule info
19+ no_prefix=${output#* -} # get rid of the prefix
20+ COMMIT=${no_prefix% * } # get rid of the suffix
21+
22+ # set up an empty temporary work directory
23+ rm -rf tmp || true # remove the tmp folder if exists
24+ mkdir tmp # create the tmp folder
25+ cd tmp # go into the tmp folder
26+
27+ # checkout the current submodule commit
28+ git init # initialise empty repo
29+ git remote add origin https://$GITHUB_ACCESS_TOKEN @$SUBMODULE_GITHUB # add origin of the submodule
30+ git fetch --depth=1 origin $COMMIT # fetch only the required version
31+ git checkout $COMMIT # checkout on the right commit
32+
33+ # move the submodule from tmp to the submodule path
34+ cd .. # go folder up
35+ rm -rf tmp/.git # remove .git
36+ mv tmp/* $SUBMODULE_PATH / # move the submodule to the submodule path
37+
38+ # clean up
39+ rm -rf tmp # remove the tmp folder
You can’t perform that action at this time.
0 commit comments