Skip to content

Instantly share code, notes, and snippets.

@alexcode
Created January 9, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexcode/dc9b2d7698b18ba54f31c43458ec2b34 to your computer and use it in GitHub Desktop.
Save alexcode/dc9b2d7698b18ba54f31c43458ec2b34 to your computer and use it in GitHub Desktop.
build:
# Get all back dependencies
backdependencies:
image: composer/composer
commands:
- composer install
# Get all front dependencies and compile them
frontdependencies:
image: node
commands:
- npm install -g bower gulp
- bower install --allow-root
- npm install
- npm test
- gulp
# Build the cache to be faster next time
cache:
mount:
- node_modules
- bower_components
- vendor
# Deploy your builds
deploy:
rsync:
user: ###YOUR_USER
host: ###YOUR_IP
port: 22
source: .
# TODO Make sure to create the directories which will host your build
target: ###YOUR_DIR/releases/$$BUILD_NUMBER_$$COMMIT
delete: false
recursive: true
exclude:
- "node_modules"
- "bower_components"
- "bower.json"
- "package.json"
- "composer.*"
- ".env.*"
- "*.md"
- "gulpfile.js"
commands:
# We go to the project folder
- cd ~/###YOUR_DIR
# create the log folder if doesn't exists
- mkdir -p apache_logs
# The first time we copy your storage folder.
- mv -n releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/storage .
# - chmod -R 775 storage
# Deleting storage folder
- rm -rf releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/storage
# Linking to storage folder of the project storage folder
- ln -s `pwd`/storage/ `pwd`/releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/storage
# Activing the dotenv file for the env
- ln -s `pwd`/.env `pwd`/releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/.env
# Issue a artisan commands
- php releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/artisan migrate --force
- php releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/artisan clear-compiled
- php releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/artisan optimize --force
- php releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/artisan queue:restart
# Activating the build
- rm current; ln -s `pwd`/releases/$$BUILD_NUMBER_$$COMMIT/###YOUR_REPO_NAME/ `pwd`/current
# Cleaning the older build
- cd releases; rm -rf `ls -A | sort -r | sed -e '1,1d'`
when:
# Deploy only on pre-prod branch
branch: [###YOUR_BRANCH]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment