Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Oyed's avatar
Level 3

Submodules?

Does Envoyer include Submodules when it clones from your repo?

0 likes
11 replies
pmall's avatar

Envoyer execute the commands you write, so write a command including submodules.

1 like
Oyed's avatar
Level 3

@pmall I know I can, but I'd rather know if Envoyer includes the recursive option when it clones the repo, which would mean I wouldn't have to do this.

pmall's avatar

Envoyer does nothing by itself it executes the command you write

Oyed's avatar
Level 3

@pmall I've done a bit more testing, and no, I've not been successful doing this. Envoyer is cloning the release when I deploy, and I can't do something like the following:

cd {release} # I am using double brackets, but Laracasts seems to filter double brackets out
git submodule init
git submodule update

As it just fails and says that there was no valid Git Repo:

fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

And Envoyer does a lot of things by itself; I cannot customise the cloning command for the default "Clone New Release" task it runs, so is there any other way I can do this?

Oyed's avatar
Level 3

@JoeDawson No - I contacted Taylor and due to how Envoyer pulls from Git, this isn't possible.

neochief's avatar

Here's a workaround. Add this as deployment hook after "Clone New Release":

cd {{release}}
rm -rf ..?* .[!.]* *
git clone -b YOUR_BRANCH YOUR_REPOSITORY_CLONE_URL .
git submodule update --init --recursive

Replace YOUR_BRANCH with a branch you use for deployments. Replace YOUR_REPOSITORY_CLONE_URL with the full url of your remote repository (i.e. [email protected]:/repo/address.git)

3 likes
OscarBatlle's avatar

@neochief Don't forget to add a symlink back of your .env file on your current release.

cd {{release}}
rm -rf ..?* .[!.]* *
git clone -b YOUR_BRANCH YOUR_REPOSITORY_CLONE_URL .
git submodule update --init --recursive
ln -s /home/forge/default/.env .env
1 like
danrichards's avatar

In my case, my repo and submodules are private so this was slightly more complicated.

On your server

  1. cd ~/.ssh && ssh-keygen
  2. cat ~/.ssh/key-for-github.pub
  3. On a github machine user or equivalent user with read access to your repos. Add your public key.
  4. By pass known hosts checks for github.com
    • sudo nano ~/.ssh/config
    • Add exception for github (below)
    • sudo chmod 644 ~/.ssh/config
Host github.com
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

On Envoyer

Add an afterdeployment hook to "Clone New Release"

cd {{release}}
rm -rf ..?* .[!.]* *
ssh-agent bash -c 'ssh-add ~/.ssh/key-for-github; git clone -b your-branch-name [email protected]:user/repo.git .; git submodule update --init --recursive'
rm -rf storage
ln -s ../../.env .env
ln -s ../../storage storage

Depending on your setup, you should also double check your app (or www-data) has permissions in storage folder.

Be mindful, you're overwriting how Envoyer clones your release. So whatever you specified in the branch name in the project settings in Envoyer does not matter anymore.

Workflow

Make sure your let your devs know about submodule updates and running locally.

git submodule update --init --recursive --remote

@neochief and @oscarbatlle IMPORTANT ! You also missed the symbolic link for the storage folder that sits outside your releases folder.

1 like

Please or to participate in this conversation.