Create variables that can be used by gitlab-ci.
Choose a project and go to settings > CI / CD > Variables (expand) :

Create a file named gitlab-ci.yml into project's root directory
Write code like this sample :
image: ubuntu
services:
- docker:dind
stages:
- deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store We're using tr to fix line endings which makes ed25519 keys work without extra
## base64 encoding. https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
- echo "$DEPLOYMENT_PPK" | tr -d '\r' | ssh-add - > /dev/null
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
deploy_staging:
stage: deploy
script:
- ssh -o "StrictHostKeyChecking=no" -p22 $DEPLOYMENT_USER "mkdir -p /home/$DEPLOYMENT_DIR/www/ && rm -rf /home/$DEPLOYMENT_DIR/www/*"
- scp -P22 -r ./* $DEPLOYMENT_USER:/home/$DEPLOYMENT_DIR/www/
environment:
name: staging
url: http://pwdgen.popallo.com
only:
- master