Created
May 24, 2018 08:08
-
-
Save gslin/20c57a14edaf1825a1287e25ba9cd4c4 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
# | |
APPLICATION_NAME?= appname | |
AWS_PROFILE?= my_aws_profile | |
AWS_REGION?= ap-northeast-1 | |
S3_BUCKET?= appname-codedeploy-ap-northeast-1 | |
# | |
GIT_BRANCH!= git rev-parse --abbrev-ref HEAD | |
GIT_DIRTY!= git diff-files --quiet; echo $$? | |
GIT_HASH!= git rev-parse HEAD | |
# | |
NOW!= date -u +%Y%m%d-%H%M%S | |
S3_KEY= ${APPLICATION_NAME}/${GIT_BRANCH}-${NOW}-${GIT_HASH} | |
# | |
.DEFAULT_GOAL:= test | |
.PHONY: build clean deploy deploy-force force-deploy help test _git_dirty | |
# | |
build: vendor | |
@true | |
clean: | |
rm -fr vendor/ | |
composer.lock: composer.json | |
composer update | |
test -e composer.lock && touch composer.lock | |
deploy: _git_dirty test deploy-force | |
@true | |
deploy-force: build | |
aws deploy push \ | |
--application-name "${APPLICATION_NAME}" \ | |
--profile "${AWS_PROFILE}" \ | |
--region "${AWS_REGION}" \ | |
--s3-location "s3://${S3_BUCKET}/${S3_KEY}" | |
aws deploy create-deployment \ | |
--application-name "${APPLICATION_NAME}" \ | |
--deployment-group-name "${GIT_BRANCH}" \ | |
--profile "${AWS_PROFILE}" \ | |
--region "${AWS_REGION}" \ | |
--s3-location bucket="${S3_BUCKET},key=${S3_KEY},bundleType=zip" | |
force-deploy: deploy-force | |
@true | |
help: | |
@echo "Availabile commands:" | |
@echo "" | |
@echo " make clean" | |
@echo " make deploy" | |
@echo " make deploy-force" | |
@echo " make force-deploy (alias to deploy-force)" | |
@echo " make help" | |
@echo " make test (default action)" | |
test: vendor | |
vendor/bin/phpcs | |
vendor/bin/phpunit | |
vendor: composer.lock | |
composer install | |
_git_dirty: | |
ifneq (${GIT_DIRTY}, 0) | |
$(error 'Git is dirty, stop deploying.') | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment