image: node:16 workflow: rules: - if: '$CI_COMMIT_BRANCH' cache: paths: - .yarn deploy: before_script: - apt update -yq # Set up rsync to dev server - apt install -y rsync - 'which ssh-agent || ( apt install openssh-client -y )' - mkdir -p ~/.ssh - eval $(ssh-agent -s) - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - ssh-add <(echo "$RSYNC_PRIVATE_KEY") - echo "$RSYNC_PRIVATE_KEY" > ~/.ssh/id_rsa # Install yarn & make it accessible - curl -o- -L https://yarnpkg.com/install.sh | bash - export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" script: - yarn install --cache-folder .yarn - yarn build - rsync -avuz -e 'ssh -i ~/.ssh/id_rsa' dist/ $RSYNC_DESTINATION rules: - if: '$CI_COMMIT_BRANCH == "main"'