Skip to content

Instantly share code, notes, and snippets.

@atillay
Last active October 29, 2024 14:58
Show Gist options
  • Save atillay/d3ba7f570e697e503c99be6f5b0bd563 to your computer and use it in GitHub Desktop.
Save atillay/d3ba7f570e697e503c99be6f5b0bd563 to your computer and use it in GitHub Desktop.
Deploy to Gandi Simple Hosting with Gitlab CI (and build assets with NPM)
image: node:lts-slim
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
stage_deploy:
tags:
- docker
only:
- master
variables:
GIT_EMAIL: [email protected]
GIT_NAME: John Doe
GIT_SERVER: {userId}@git.sd{X}.gpaas.net
SFTP_SERVER: {userId}@sftp.sd{X}.gpaas.net
GIT_REPO: {repoName}.git
script:
- git config --global user.email "$GIT_EMAIL" && git config --global user.name "$GIT_NAME"
- git remote add gandi git+ssh://$GIT_SERVER/$GIT_REPO
- git push gandi master
- ssh $GIT_SERVER clean $GIT_REPO
- ssh $GIT_SERVER deploy $GIT_REPO
- npm install && npm run build # optional : build assets
- sftp $SFTP_SERVER <<< $'put -r ./htdocs/wp-content/themes/{theme}/dist/* /lamp0/web/vhosts/{vhost}/htdocs/wp-content/themes/{theme}/dist/' # optional : upload assets
@ligne13
Copy link

ligne13 commented Oct 29, 2024

I had to add those two lines before git push gandi master:

  • git fetch --unshallow
  • git checkout master

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