Created
April 19, 2018 14:51
-
-
Save t-cyrill/91393876ec369f1f1701948b4a648771 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
--- | |
version: 0.4 | |
# Global environment variables | |
env: | |
DEPLOY_TO: /tmp/deploy | |
REVISION: 0 | |
LEAVE: 5 | |
networks: | |
local: | |
hosts: | |
- localhost | |
commands: | |
clean_tmp: | |
desc: clean deploy tmp directory | |
run: rm -rf $DEPLOY_TO/tmp/* | |
make_deploy_target: | |
desc: make deploy target directories | |
run: mkdir -p $DEPLOY_TO/tmp $DEPLOY_TO/releases/$REVISION | |
before_deploy: | |
desc: call before_deploy | |
run: echo BeforeDeploy | |
deploy: | |
desc: copy dist directory | |
upload: | |
- src: ./dist/ | |
dst: $DEPLOY_TO/tmp | |
move_dist_to_releases: | |
desc: Move tmp/dist directory to releases | |
run: mv -f $DEPLOY_TO/tmp/dist/* $DEPLOY_TO/releases/$REVISION | |
link_current_to_releases: | |
desc: Make symlink to releases directory | |
run: ln -nsf $DEPLOY_TO/releases/$REVISION $DEPLOY_TO/current | |
after_deploy: | |
desc: call after_deploy | |
run: echo AfterDeploy | |
remove_old_releases: | |
desc: Remove old releases | |
run: | | |
cd $DEPLOY_TO/releases | |
NUM_OF_RELEASES=$(ls | wc -l) | |
REMOVE_NUM=$(( $NUM_OF_RELEASES - $LEAVE )) | |
if [ $REMOVE_NUM -gt 0 ]; then | |
ls | cat | sort | head -n $REMOVE_NUM | xargs rm -rf | |
fi | |
exit 0 | |
targets: | |
all: | |
- clean_tmp | |
- make_deploy_target | |
- before_deploy | |
- deploy | |
- move_dist_to_releases | |
- link_current_to_releases | |
- after_deploy | |
- remove_old_releases |
This file contains hidden or 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
--- | |
version: 0.4 | |
# Global environment variables | |
env: | |
DEPLOY_TO: /tmp/deploy | |
networks: | |
local: | |
hosts: | |
- localhost | |
commands: | |
clean_dist: | |
desc: clean in dist directory | |
local: rm -rf dist/* | |
make_dist_dir: | |
desc: make dist directory | |
local: mkdir -p dist/ | |
copy_to_dist_dir: | |
desc: copy current revision files to dist directory | |
local: git checkout-index -a -f --prefix=dist/ | |
call_deploy: | |
desc: call deploy | |
local: ./sup -e REVISION=$(date "+%Y%m%d%H%M%S") -f ./config/deploy/Supfile $SUP_ENV $SUP_NETWORK all | |
targets: | |
deploy: | |
- clean_dist | |
- make_dist_dir | |
- copy_to_dist_dir | |
- call_deploy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment