Skip to content

Instantly share code, notes, and snippets.

@petrbel
Forked from iedemam/gist:9830045
Last active October 26, 2019 10:29
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save petrbel/c3bf7e0f59c22a52f534 to your computer and use it in GitHub Desktop.
Save petrbel/c3bf7e0f59c22a52f534 to your computer and use it in GitHub Desktop.
Travis-CI submodules
# Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior!
# disable the default submodule logic
git:
submodules: false
# use sed to replace the SSH URL with the public URL, then init and update submodules
before_install:
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
@empeje
Copy link

empeje commented Oct 16, 2018

You'd better directly use https in your .gitmodules instead

Copy link

ghost commented Oct 26, 2019

@empeje but then you force every collaborator on the project to authenticate with username/password when checking out the submodules, no?

@empeje
Copy link

empeje commented Oct 26, 2019

Hi @kytwb, it is a long time since I comment to this .travis.yml. I was a stubborn boy back then and didn't give any context when I put a comment.

It is a long time since I use submodules, I didn't have the answer.

Copy link

ghost commented Oct 26, 2019

No worries, genuinely curious. I had to implement that hack as well on one of my opensource repository.

@empeje
Copy link

empeje commented Oct 26, 2019

I think I remember

use sed to replace the SSH URL with the public URL, then init and update submodules

before_install:
 - sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
 - git submodule update --init --recursive

I think I advice the author of this gist to directly using https instead of replacing it from git url to https url. GitHub has deploy key that you can use for individual repository to do some hack for the CI. Then I guess you can leverage Travis encryption to have the key committed to the repository safely on the public. Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment