Created
May 28, 2020 02:22
-
-
Save andregaldino/fe707351763d5dc86319ef3f75a8ed08 to your computer and use it in GitHub Desktop.
Laravel Gitlab CI - Laravel Deployer - PHP 7.4
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: php:7.4 | |
before_script: | |
- apt-get update -yqq | |
- apt-get install -yqq libmcrypt-dev libmagickwand-dev --no-install-recommends | |
- apt-get install -yqq git libssl-dev libmpdec-dev libonig-dev libzip-dev libpng-dev rsync | |
- docker-php-ext-install pdo_mysql mbstring zip gd | |
- curl -sS https://getcomposer.org/installer | php | |
.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 | |
.change_file_permissions: &change_file_permissions | | |
find . -type f -not -path "./vendor/*" -exec chmod 664 {} \; | |
find . -type d -not -path "./vendor/*" -exec chmod 775 {} \; | |
build: | |
stage: build | |
cache: | |
key: ${CI_COMMIT_REF_SLUG}-composer | |
paths: | |
- vendor/ | |
script: | |
- cp .env.example .env | |
- php artisan key:generate | |
- php composer.phar install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts | |
artifacts: | |
expire_in: 1 month | |
paths: | |
- vendor/ | |
- .env | |
phpunit: | |
stage: test | |
script: | |
- vendor/bin/phpunit --configuration phpunit.xml --coverage-text --colors=never | |
develop: | |
stage: deploy | |
script: | |
- *init_ssh | |
- *change_file_permissions | |
- php artisan deploy domain -s local --branch=${CI_COMMIT_REF_NAME} --revision=${CI_COMMIT_SHA} | |
environment: | |
name: develop | |
url: http://domain | |
only: | |
- develop | |
production: | |
stage: deploy | |
script: | |
- *init_ssh | |
- *change_file_permissions | |
- php artisan deploy domain.com -s local --branch=${CI_COMMIT_REF_NAME} --revision=${CI_COMMIT_SHA} | |
environment: | |
name: production | |
url: https://www.domain.com | |
when: manual | |
only: | |
- /^v-/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment