Skip to content

Instantly share code, notes, and snippets.

@milch
Created February 5, 2016 07:16
Show Gist options
  • Save milch/42acf1431ac9267d1b31 to your computer and use it in GitHub Desktop.
Save milch/42acf1431ac9267d1b31 to your computer and use it in GitHub Desktop.
update_fastlane
fastlane_version "1.57.0"
before_all do
ensure_git_status_clean
end
lane :build do |p|
ensure_docker_machine_available
docker_build(
tag: p[:version_number],
repository: "example-org/my-project",
path: "server"
)
docker_push
end
lane :staging do
timestamp = DateTime.now.strftime("%Y%m%d%H%M%S")
build version_number: timestamp
update_task_definition environment: "staging", version_number: timestamp
add_git_tag(build_number: timestamp)
push_git_tags
end
lane :production do |p|
throw "Please set the version number using 'version:<version_number>'" if p[:version].nil?
update_task_definition environment: "production", version_number: p[:version]
end
private_lane :update_task_definition do |params|
environment = params[:environment]
# Terraform will update the ECS Task Definition and ECS Service with the new build version
# ECS will automatically pick up the change and issue a deployment
# Any other infrastructure changes will also automatically be applied on deploy
terraform(
var_file: "#{environment}.tfvars",
vars: {
server_version: params[:version_number]
},
state_file: "#{environment}.tfstate",
infrastructure_folder: "infrastructure"
)
git_commit(
path: "infrastructure/#{environment}.tfstate",
message: "Updated State"
)
end
after_all do |lane|
push_to_git_remote
end
error do |lane, exception|
end
# vim: ft=ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment