This is considering using linode with a froxlor install - so it user / user repo / domain are already created) :
*vim /etc/sudoers
- add a line
gitlab-runner ALL=(myuser:group) NOPASSWD:ALL
- change myuser:group accordingly
- then
:wq!
cd /var/customers/webs/myuser
mkdir .ssh
if not donechown -R myuser:mysusergroup .ssh
sudo -u myuser ssh-keygen -t rsa
- Store it in /var/customers/webs/myuser/.ssh
- ! use NO PASSWORD - as gitlab deploy won't be able to write it :)
- Copy public key --->
cat .ssh/id_rsa.pub
, highlight and copy (unless you have xclip and X11 forwarding is enabled)
- click [https://gitlab.com/users/sign_in?redirect_to_referer=yes]
- Paste id_rsa.pub it in gitlab > Project > Settings->Repositories->Deploy Keys https://gitlab.com/account/mysite/settings/repository#js-deploy-keys-settings
- Leave "Write access allowed" unticked
cd /var/customers/webs/myuser/dev.myuser.servername.io/wp-content/themes/
sudo -u myuser git clone gitlabRepo@gitlab
- ! use ssh - not https
- ! make sure git clone doesn't prompt for a password
In gitlab > Project > Settings->Repositories->Deploy Keys
- Copy public key from server/xyz/myuser/.ssh/id_rsa.pub
- Paste it in a new Deploy key - use myuser as user name
- disable SharedRunner
- enable the Specific Runner
- Add a variable
DEPLOY_DIR
(ex: /var/customers/webs/user/usersite-prod.com/wp-content/themes/usertheme - or any theme/repo folder) - Add a variable
DEPLOY_DIR_DEV
(ex: /var/customers/webs/user/usersite-dev.com/wp-content/themes/usertheme - or any theme/repo folder) - Add variable
PROJ_OWNER
(ex: user - same as ssh user / project linode user) - Add variable
PROD_URL
andSTAGING_URL
(https://mysite.com)
Add .gitlab-ci.yml with the following :
Click edit to get the clean code of this gist OR BETTER : use one of the joined file with extended .gitlab-ci.yml depending on your needs (one gives staging and prod, the other provides a build with npm
and yarn
). Adjust accoprdingly.
If you use gitlab-ci-npm.yml, you need to add also the file nodescript.sh
.
- Then commit
- change something (ex: README.md, or add a file)
- commit
- push to master
- Check if job is in gitlab > Pipelines > Jobs
- If not, it is possible to run it again or check what is going on
Enable runners ;)
- run
getent passwd myuser
- it should issue something like
myuser:x:10009:10009:Froxlor Customer:/var/customers/webs/myuser/:/bin/false
- then
vim /etc/passwd
- paste
myuser:x:10009:10009:Froxlor Customer:/var/customers/webs/myuser/:/bin/false
- you might also
sudo service nginx restart
if something goes wrong
- run
service nscd restart
cf https://linux.die.net/man/8/nscd
- edit
vim ./resources/assets/config.json
- change devUrl and publicPath
- create nodescript.sh (or nodescript-dev.sh and nodescript-prod.sh if needed) / these scripts will be ran with CI based on gitlab-ci.yml