Skip to content

Instantly share code, notes, and snippets.

@andregaldino
Last active June 1, 2021 17:07
Show Gist options
  • Save andregaldino/c85b51031ab29ddb358a508e0c124e6b to your computer and use it in GitHub Desktop.
Save andregaldino/c85b51031ab29ddb358a508e0c124e6b to your computer and use it in GitHub Desktop.
Vue Gitlab CI - Node 10
image: node:10-alpine
.init_ssh: &init_ssh |
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
.requirements: &requirements |
apk update && apk add --no-cache rsync openssh build-base gcc autoconf automake libtool zlib-dev libpng-dev nasm
variables:
HOST_DEPLOY: 127.0.0.1
USER_DEPLOY: deployer
PATH_DEPLOY: '/var/www/deploys/domain.com'
RELEASE_PATH: "${PATH_DEPLOY}/releases/${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}"
build:
stage: build
script:
- *requirements
- yarn install
- yarn build:ci
test:
stage: test
script:
- yarn install
- yarn lint
- yarn test
deploy:
stage: deploy
script:
- *requirements
- *init_ssh
- NODE_ENV=development yarn install
- yarn build:ci
- ssh ${USER_DEPLOY}@${HOST_DEPLOY} "mkdir -p ${RELEASE_PATH}"
- rsync -ra --delete dist/ "${USER_DEPLOY}@${HOST_DEPLOY}:${RELEASE_PATH}"
- ssh ${USER_DEPLOY}@${HOST_DEPLOY} "ln -sfn ${RELEASE_PATH} ${PATH_DEPLOY}/current"
only:
- /^v-/
variables:
NODE_ENV: production
VUE_APP_API_BASE_URL: https://domain.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment