Skip to content

Instantly share code, notes, and snippets.

@necolas
Last active January 1, 2016 21:09
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save necolas/8201662 to your computer and use it in GitHub Desktop.
Save necolas/8201662 to your computer and use it in GitHub Desktop.
Ghetto git deployment
BUILD_DIR := ./build
STAGING_REPO = ssh://user@hostname/~/staging.example.git
PROD_REPO = ssh://user@hostname/~/example.git
install:
npm install
# Deploy tasks
staging: build git-staging deploy
@ git tag -f staging
@ echo "Staging deploy complete"
prod: build git-prod deploy
@ git tag -f production
@ echo "Production deploy complete"
# Build tasks
build: clean
# whatever your build step is
# Sub-tasks tasks
clean:
@ rm -rf $(BUILD_DIR)
git-prod:
@ cd $(BUILD_DIR) && \
git init && \
git remote add origin $(PROD_REPO)
git-staging:
@ cd $(BUILD_DIR) && \
git init && \
git remote add origin $(STAGING_REPO)
deploy:
@ cd $(BUILD_DIR) && \
git add -A && \
git commit -m "Release" && \
git push -f origin +master:refs/heads/master
.PHONY: install build clean deploy git-prod git-staging prod staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment