Advertisement
Guest User

Untitled

a guest
Mar 13th, 2020
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.50 KB | None | 0 0
  1. image: lorisleiva/laravel-docker:latest
  2.  
  3. .init_ssh: &init_ssh |
  4.  eval $(ssh-agent -s)
  5.   echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  6.   mkdir -p ~/.ssh
  7.   chmod 700 ~/.ssh
  8.   [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
  9.  
  10. # Replace the last line with the following lines if you'd rather
  11. # leave StrictHostKeyChecking enabled (replace yourdomain.com):
  12. #
  13. #  ssh-keyscan yourdomain.com >> ~/.ssh/known_hosts
  14. #  chmod 644 ~/.ssh/known_hosts
  15.  
  16. .change_file_permissions: &change_file_permissions |
  17.  find . -type f -not -path "./vendor/*" -exec chmod 664 {} \;
  18.   find . -type d -not -path "./vendor/*" -exec chmod 775 {} \;
  19.  
  20. build:
  21.   stage: build
  22.   cache:
  23.    key: ${CI_COMMIT_REF_SLUG}
  24.    paths:
  25.    - node_modules/
  26.     - vendor/
  27.   services:
  28.    - mariadb:latest
  29.   variables:
  30.     MYSQL_DATABASE: "test"
  31.     MYSQL_ROOT_PASSWORD: "secret"
  32.     MYSQL_ROOT_HOST: "%"
  33.   script:
  34.    - composer install --no-interaction --no-progress  --prefer-dist --optimize-autoloader --ignore-platform-reqs
  35.     - cp .env.testing .env
  36.     - php artisan key:generate
  37.     - php artisan config:cache
  38.    #- php artisan route:cache
  39.     - npm install
  40.     - npm run prod
  41.     - php artisan migrate --seed
  42.     - php artisan storage:link
  43.     - php artisan serve &
  44.     - vendor/bin/phpunit
  45.   artifacts:
  46.    expire_in: 1 month
  47.    paths:
  48.     - vendor/
  49.      - node_modules/
  50.      - public/css/
  51.      - public/js/
  52.  
  53. codestyle:
  54.   stage: test
  55.   dependencies:
  56.    - build
  57.   script:
  58.    - phpcs --standard=PSR2 --extensions=php --ignore=app/Support/helpers.php app
  59.  
  60. #phpunit:
  61. #  stage: test
  62. #  dependencies:
  63. #    - build
  64. #  script:
  65. #    - php artisan key:generate
  66. #    - php artisan serve &
  67. #    - vendor/bin/phpunit
  68.  
  69. staging:
  70.   stage: deploy
  71.   script:
  72.    - *init_ssh
  73.     - *change_file_permissions
  74.     # copy .env.development to .env
  75.     - cp .env.staging .env
  76.     - php artisan key:generate
  77.     - php artisan config:clear
  78.     - php artisan config:cache
  79.     - php artisan deploy dev.mydomain.ch -s upload
  80.   environment:
  81.     name: staging
  82.     url: http://dev.mydomain.ch
  83.   only:
  84.    - master
  85.  
  86. production:
  87.   stage: deploy
  88.   script:
  89.    - *init_ssh
  90.     - *change_file_permissions
  91.     # copy .env.production to .env
  92.     - cp .env.production .env
  93.     - php artisan key:generate
  94.     - php artisan config:cache
  95.     - php artisan deploy mydomain.ch -s upload
  96.   environment:
  97.     name: production
  98.     url: http://mydomain.ch
  99.   when: manual
  100.   only:
  101.   - master
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement