Last active
October 29, 2024 14:58
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to add those two lines before git push gandi master: