Although it's been a while here my two cents.
I'm glad the given answers where pointing me in the right direction, however I still had to struggle with this quite some time.
Here is my summary:
Using submodules in Plesk
- repos to be integrated as submodules must not be privat
- Don't
ssh
! To integrate an external repo we must use https
protocol: git submodule add https://github.com/example.repo.git
- see https://github.com/docker-library/golang/issues/148
- the ${HOME} user (see code below) is used to authorize against github, so his key pair needs to be generated and the public key must be stored at Github
ssh
into your account using the ${HOME}
users name and password. In Plesk the ${HOME}
user is the owner of the subscription domain.com
or sub.domain.com
belongs to.
- to generate a key pair do:
ssh-keygen -t rsa
- key pairs are automatically stored under the users home directory:
${HOME}/.ssh/id_rsa
and ${HOME}/.ssh/id_rsa.pub
- copy the generated public key over to Github
Usage
(under "Additional deployment actions")
git --git-dir=${HOME}/git/example.repo.git --work-tree=. submodule update --init &> ~/logs/git/example.repo.log
git --git-dir=${HOME}/git/example.repo.git --work-tree=. checkout master &>> ~/logs/git/example.repo.log
git --git-dir=${HOME}/git/example.repo.git --work-tree=. pull origin master &>> ~/logs/git/example.repo.log
git --git-dir=${HOME}/git/example.repo.git --work-tree=. submodule update --init --recursive &>> ~/logs/git/example.repo.log
git commit -am "submodule updated $(date)"
or the short way
git --git-dir=${HOME}/git/example.repo.git --work-tree=. submodule foreach 'git submodule update --init;git checkout master;git pull origin master;git submodule update --init --recursive;' &> ~/logs/git/example.repo.log
git commit -am "submodule updated $(date)"
Explanation: we must use --git-dir
and --work-tree
here because of Plesks folder structure. Normally .git
files are located within the main repository folder. Here these files are in its own git
folder:
-- domain.com
-- git
-- example.repo.git
-- sub.domain.com