Created
March 25, 2020 12:16
-
-
Save wilcorrea/bf4df19ee675d89425d73da5c2ec7575 to your computer and use it in GitHub Desktop.
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: docker:git | |
before_script: | |
- git config --global user.email "[email protected]" | |
- git config --global user.name "My Company" | |
stages: | |
# - test | |
- development | |
- stage | |
- production | |
#test: | |
# stage: test | |
# only: | |
# - merge_requests | |
# - dev | |
# - homolog | |
# - master | |
# script: | |
# - echo "run tests!" | |
development: | |
stage: development | |
only: | |
- dev | |
script: | |
- git checkout dev | |
- git branch -vv | |
- rm -rf .git | |
- git init | |
- git add . | |
- touch "$(pwd)/.env" | |
- cat "${DEPLOY_DEVELOP_ENV}" > "$(pwd)/.env" | |
- cp .docker/docker-compose.yml docker-compose.yml | |
- git add -f .env | |
- git add -f docker-compose.yml | |
- git commit --quiet -m "[deploy] $(date)" | |
- DEPLOY_REMOTE="https://${DEPLOY_DEVELOP_USER}:${DEPLOY_DEVELOP_PASSWORD}@${DEPLOY_DEVELOP_PATH}" | |
- echo "Deploy 'dev' (https://${DEPLOY_DEVELOP_PATH})" | |
- git remote add deploy ${DEPLOY_REMOTE} | |
- git push deploy master --force | |
stage: | |
stage: stage | |
only: | |
- homolog | |
script: | |
- git checkout homolog | |
- git branch -vv | |
- rm -rf .git | |
- git init | |
- git add . | |
- touch "$(pwd)/.env" | |
- cat "${DEPLOY_HOMOLOG_ENV}" > "$(pwd)/.env" | |
- cp .docker/docker-compose.yml docker-compose.yml | |
- git add -f .env | |
- git add -f docker-compose.yml | |
- git commit --quiet -m "[deploy] $(date)" | |
- DEPLOY_REMOTE="https://${DEPLOY_HOMOLOG_USER}:${DEPLOY_HOMOLOG_PASSWORD}@${DEPLOY_HOMOLOG_PATH}" | |
- echo "Deploy 'homolog' (https://${DEPLOY_HOMOLOG_PATH})" | |
- git remote add deploy ${DEPLOY_REMOTE} | |
- git push deploy master --force | |
production: | |
stage: production | |
only: | |
- master | |
script: | |
- git checkout master | |
- git branch -vv | |
- rm -rf .git | |
- git init | |
- git add . | |
- touch "$(pwd)/.env" | |
- cat "${DEPLOY_MASTER_ENV}" > "$(pwd)/.env" | |
- cp .docker/docker-compose.yml docker-compose.yml | |
- git add -f .env | |
- git add -f docker-compose.yml | |
- git commit --quiet -m "[deploy] $(date)" | |
- DEPLOY_REMOTE="https://${DEPLOY_MASTER_USER}:${DEPLOY_MASTER_PASSWORD}@${DEPLOY_MASTER_PATH}" | |
- echo "Deploy 'master' (https://${DEPLOY_MASTER_PATH})" | |
- git remote add deploy ${DEPLOY_REMOTE} | |
- git push deploy master --force |
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: tevun/quasar:latest | |
cache: &global_cache | |
key: ${CI_COMMIT_REF_SLUG} | |
paths: | |
- quasar/node_modules/ | |
policy: pull-push | |
before_script: | |
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' | |
- eval "$(ssh-agent -s)" | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
- echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa | |
- chmod 600 ~/.ssh/id_rsa | |
- ssh-add ~/.ssh/id_rsa | |
- git config --global user.email "[email protected]" | |
- git config --global user.name "CI" | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
development: | |
only: | |
- development | |
script: | |
- echo "Add host ${DEVELOPMENT_DEPLOY_HOST}" | |
- ssh-keyscan -H "${DEVELOPMENT_DEPLOY_HOST}" > ~/.ssh/known_hosts | |
- chmod 644 ~/.ssh/known_hosts | |
- echo "Deploy to ${DEVELOPMENT_DEPLOY_REMOTE}" | |
- bash "${PWD}/dist/stage/deploy.sh" "stage" "${DEVELOPMENT_DEPLOY_REMOTE}" | |
master: | |
only: | |
- master | |
script: | |
- echo "Add host ${MASTER_DEPLOY_HOST}" | |
- ssh-keyscan -H "${MASTER_DEPLOY_HOST}" > ~/.ssh/known_hosts | |
- chmod 644 ~/.ssh/known_hosts | |
- echo "Deploy to ${MASTER_DEPLOY_REMOTE}" | |
- bash "${PWD}/dist/production/deploy.sh" "production" "${MASTER_DEPLOY_REMOTE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment