Skip to content

Instantly share code, notes, and snippets.

@MekDrop
Created December 5, 2016 16:12
Show Gist options
  • Save MekDrop/c1d954208717fc31c106f33b8cffa66f to your computer and use it in GitHub Desktop.
Save MekDrop/c1d954208717fc31c106f33b8cffa66f to your computer and use it in GitHub Desktop.
GitLab CI: deploy PHP website with git-ftp over sftp
# This script should work however sftp is not supported in compiled curl so not everything fine here
#
# $_CI* vars should be defined in project variables
image: mwienk/docker-git-ftp
before_script:
- eval `ssh-agent -s`
- cat > deploy.key <(echo "$CI_SERVER_KEY")
- chmod 0600 deploy.key
- ssh-add deploy.key
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh $CI_SERVER_USER@$CI_SERVER_HOST "cd $CI_SERVER_PATH; pwd"
deploy_all:
stage: deploy
script:
- git ftp init -u $CI_SERVER_USER --branch master --remote-root $CI_SERVER_PATH --verbose --key deploy.key --insecure sftp://$CI_SERVER_HOST
- ssh $CI_SERVER_USER@$CI_SERVER_HOST "cd $CI_SERVER_PATH; composer update"
only:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment