Skip to content

Commit

Permalink
Update tasks for deploying sandbox app (#255)
Browse files Browse the repository at this point in the history
* Add a readme to the sandbox template

It's good to explain what the repo actually is

* Update Rake task for deploying sandbox app

- Bunder.with_clean_env is deprecated. I'm not sure if
  `with_unbundled_env` is the correct option, but it seems to do the
  job.
- Use SSL version of git clone to avoid having to use a username and
  password. SSL makes sense if deploying from the local machine: maybe
  at some point this was deployed automatically, but I can't see any
  trace of that.
- Temporarily lock to building on the latest Rails 5 version: the
  sandbox app is locked to use Rails 5, and Godmin isn't very well
  supported on Rails 6 yet.
  • Loading branch information
dgmstuart authored May 3, 2021
1 parent 3334ff0 commit a2e4f34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ namespace :sandbox do
task :deploy do
message = "Generated from: https://github.com/varvet/godmin/commit/#{`git rev-parse HEAD`.strip}"
template_path = File.expand_path("../template.rb", __FILE__)
Bundler.with_clean_env do
Bundler.with_unbundled_env do
Dir.mktmpdir do |dir|
Dir.chdir(dir)
system("git clone https://github.com/varvet/godmin-sandbox.git")
system("git clone git@github.com:varvet/godmin-sandbox.git")
if $CHILD_STATUS.success?
Dir.chdir("godmin-sandbox")
system("rm -rf *")
system("rails new . -d postgresql -m #{template_path} --without-engine --skip-spring")
system("rails _5.2.5_ new . -d postgresql -m #{template_path} --without-engine --skip-spring")
if $CHILD_STATUS.success?
system("git add --all")
system("git commit -m '#{message}'")
Expand Down
14 changes: 14 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def install_standalone
modify_author_service
modify_article_controller
modify_article_service
modify_readme

migrate_and_seed
end
Expand Down Expand Up @@ -64,6 +65,7 @@ def install_engine
modify_author_service("admin")
modify_article_controller("admin")
modify_article_service("admin")
modify_readme

migrate_and_seed
end
Expand Down Expand Up @@ -308,6 +310,18 @@ def batch_action_destroy(authors)
end
end

def modify_readme
readme_file = "README.md"
run "rm #{readme_file}"
readme_text = <<~README
# README
This is the source code for a demo application of the [Godmin](https://github.com/varvet/godmin) admin framework for Rails.
It is generated by running `rake sandbox:deploy` inside the Godmin repo.
README
File.open(readme_file, 'w') { |file| file.write(readme_text) }
end

def migrate_and_seed
rake("db:migrate")
rake("db:seed")
Expand Down

0 comments on commit a2e4f34

Please sign in to comment.