Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A "how to" guide for private submodules on Vercel

NotificationsYou must be signed in to change notification settings

beeinger/vercel-private-submodule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Short and easy tutorial for using private submodules on Vercel

💡 [Approach 1 - .gitmodules]

📋 Instructions 🚀

Edit your.gitmodules to follow this schema:

[submodule "<repo-name>"]path = <folder-name>url = https://<github-token>@github.com/<owner-name>/<repo-name>.git

The important part is the<github-token> inhttps://<github-token>@github.com/<owner-name>/<repo-name>.git

You can use either a classic token or a fine-grained token with necessary permissions.

💡 TIP: If you dont know how to get ithave a look at this

🤫 If you don't want to commit the token

Use this trick - add.gitmodules to.gitignore and then put the whole contents of the.gitmodules in a GitHub Secret or a secret on Vercel, and then when installing dependencies and doing setup, do smthn likeecho '${{ secrets.GITMODULES }}' > .gitmodules

🔐 Best to use a fine-grained token with readonly access only to the repos you have as submodules.

🎉 That's it! 🎉

🤝🏽 Thanks@FrameMuse [Issue:#7]


💡 [Approach 2 - Script]

📋 Step by step 🚀

  • copy the ./vercel-submodule-workaround.sh to the root of your project

  • make sure the file is executable - run this command:

    chmod u+x vercel-submodule-workaround.sh
  • in your package.json add a script:

    {"scripts":{"vercel-install":"./vercel-submodule-workaround.sh && yarn --ignore-scripts --production=false",    }}

    Info:

    --production=false ensures that dev-dependencies will be installed, if you dont need your dev-dependencies to install then just delete this flag.

    --ignore-scripts ignores pre and post install scripts if you want the scripts to run delete this flag.

  • Tell Vercel to use vercel-install instead of the defalt install command

    • project -> Settings -> General => Build & Development Settings

    • in INSTALL COMMAND type

    yarn vercel-install# ornpm vercel-install
    • toggle OVERRIDE on
  • Create a Github access token

    • Settings -> Developer settings -> Personal access tokens

    • Generate new token

    • set a note (eg. vercel)

    • set expiration to whatever you see fit (eg. No expiration)

    • select repo

      [x] repo - Full control of private repositories

    • copy the generated token

  • Add the token to Vercel Environment Variables

    • Project -> Settings -> Environment Variables

    • add a new variable called GITHUB_ACCESS_TOKEN and with value of the token you just copied

🎉 That's it! 🎉


+ Post Scriptum

I haven't added support for multiple submodules but it should be easy enough, try edditing this part and then the rest of the script.

# get submodule commitoutput=`git submodule status --recursive`# get submodule infono_prefix=${output#*-}# get rid of the prefixCOMMIT=${no_prefix%*}# get rid of the suffix

About

A "how to" guide for private submodules on Vercel

Topics

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp