Deploy your Middleman build to a specific branch on a git repository, so you can either host it on github pages, or use an approach like DHH does in kamal-skiff.
This gem is a fork and reduction of the original middleman-deploy to support git only (the other approaches felt a bit old skool).
gem 'middleman-deploy-git', '~> 1.0'$ middleman build [--clean]
$ middleman deploy [--build-before]
Middleman-deploy-git can deploy a site via git.
Make sure that git is installed, and activate the extension by adding the
following to config.rb:
activate :deploy do |deploy|
# Optional Settings
# deploy.remote = 'custom-remote' # remote name or git url, default: origin
# deploy.branch = 'custom-branch' # default: gh-pages
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
endIf you use a remote name, you must first add it using git remote add. Run
git remote -v to see a list of possible remote names. If you use a git url,
it must end with '.git'.
Afterwards, the build directory will become a git repo.
If you use the force push strategy, this branch will be created on the remote if
it doesn't already exist.
But if you use the submodule strategy, you must first initialize build folder as
a submodule. See git submodule add documentation.
To automatically run middleman build during middleman deploy, turn on the
build_before option while activating the deploy extension:
activate :deploy do |deploy|
# ...
deploy.build_before = true # default: false
endDeploy your site to more than one configuration using environment variables.
# config.rb
case ENV['TARGET'].to_s.downcase
when 'production'
activate :deploy do |deploy|
deploy.branch = 'production'
end
else
activate :deploy do |deploy|
deploy.branch = 'staging'
end
end# Rakefile
namespace :deploy do
def deploy(env)
puts "Deploying to #{env}"
system "TARGET=#{env} bundle exec middleman deploy"
end
task :staging do
deploy :staging
end
task :production do
deploy :production
end
end$ rake deploy:staging
$ rake deploy:production
This gem is based on the great work done on the original: middleman-deploy.