Skip to content

Instantly share code, notes, and snippets.

@exileed
Created September 6, 2018 12:38
Show Gist options
  • Save exileed/bf7df52b01da8e03687427c3d879c7ca to your computer and use it in GitHub Desktop.
Save exileed/bf7df52b01da8e03687427c3d879c7ca to your computer and use it in GitHub Desktop.
.gitlab-ci laravel
image: lorisleiva/laravel-docker:latest
before_script:
- mkdir -p ~/.ssh
- echo "$PACKAGE_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- mysql -h $DB_HOST -u root -p$MYSQL_ROOT_PASSWORD -e "SHOW DATABASES;"
composer:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor/
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
artifacts:
expire_in: 1 month
paths:
- vendor/
- .env
npm:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-npm
paths:
- node_modules/
script:
- npm install
- npm run production
artifacts:
expire_in: 1 month
paths:
- node_modules/
- public/css/
- public/js/
codestyle:
stage: test
dependencies: []
script:
- phpcs --standard=PSR2 --extensions=php --ignore=app/Support/helpers.php app
phpunit:
stage: test
dependencies:
- composer
script:
- phpunit --coverage-text --colors=never
staging:
stage: deploy
script:
- *init_ssh
- *change_file_permissions
- php artisan deploy dev.yourdomain.com -s upload
environment:
name: staging
url: http://dev.yourdomain.com
only:
- master
production:
stage: deploy
script:
- *init_ssh
- *change_file_permissions
- php artisan deploy yourdomain.com -s upload
environment:
name: production
url: http://yourdomain.com
when: manual
only:
- master
image: lorisleiva/laravel-docker:latest
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
codestyle:
stage: test
cache: {}
script:
- phpcs --standard=PSR2 --extensions=php app
phpunit:
stage: test
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
- phpunit --coverage-text --colors=never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment