forked from Shopify/shipit-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.rb
94 lines (79 loc) · 2.95 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Template for rails new app
# Run this like `rails new shipit -m template.rb`
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("4.2.0")
raise Thor::Error, "You need at least Rails 4.2.0 to install shipit"
end
route %(mount Shipit::Engine, at: '/')
gem 'sidekiq'
gem 'thin'
gem 'shipit-engine', github: 'Shopify/shipit-engine'
gem 'dotenv-rails'
say("These configs are for development, you will have to generate them again for production.",
Thor::Shell::Color::GREEN, true)
say("Shipit requires a GitHub application to authenticate users. "\
"If you haven't created an application on GitHub yet, you can do so at https://github.com/settings/applications/new",
Thor::Shell::Color::GREEN, true)
github_id = ask("What is the application client ID?")
github_secret = ask("What is the application client secret?")
say("Shipit needs API access to GitHub.")
say("Create an API key at https://github.com/settings/tokens/new that has these permissions: "\
"admin:repo_hook, admin:org_hook, repo", Thor::Shell::Color::GREEN, true)
github_token = ask("What is the github key?")
create_file '.env', <<-CODE
GITHUB_OAUTH_ID=#{github_id}
GITHUB_OAUTH_SECRET=#{github_secret}
GITHUB_API_TOKEN=#{github_token}
CODE
create_file 'Procfile', <<-CODE
web: bundle exec rails s
worker: bundle exec sidekiq -c 1
CODE
create_file 'config/secrets.yml', <<-CODE, force: true
development:
secret_key_base: #{SecureRandom.hex(64)}
host: 'http://localhost:3000'
github_oauth: # Head to https://github.com/settings/applications/new to generate oauth credentials
id: <%= ENV['GITHUB_OAUTH_ID'] %>
secret: <%= ENV['GITHUB_OAUTH_SECRET'] %>
# team: MyOrg/developers # Enable this setting to restrict access to only the member of a team
github_api:
access_token: <%= ENV['GITHUB_API_TOKEN'] %>
redis_url: redis://localhost
test:
secret_key_base: #{SecureRandom.hex(64)}
host: 'http://localhost:4000'
github_oauth:
id: 1d
secret: s3cr3t
github_api:
access_token: t0k3n
redis_url: redis://localhost
production:
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
host: <%= ENV['SHIPIT_HOST'] %>
github_oauth:
id: <%= ENV['GITHUB_OAUTH_ID'] %>
secret: <%= ENV['GITHUB_OAUTH_SECRET'] %>
# team: MyOrg/developers # Enable this setting to restrict access to only the member of a team
github_api:
access_token: <%= ENV['GITHUB_API_TOKEN'] %>
redis_url: <%= ENV['REDIS_URL'] %>
env:
# SSH_AUTH_SOCK: /foo/bar # You can set environment variable that will be present during deploys.
CODE
initializer 'sidekiq.rb', <<-CODE
Rails.application.config.active_job.queue_adapter = :sidekiq
Sidekiq.configure_server do |config|
config.redis = { url: Shipit.redis_url.to_s }
end
Sidekiq.configure_client do |config|
config.redis = { url: Shipit.redis_url.to_s }
end
CODE
after_bundle do
rake 'railties:install:migrations db:create db:migrate'
git :init
run "echo '.env' >> .gitignore"
git add: '.'
git commit: "-a -m 'Initial commit'"
end