Skip to content

Commit

Permalink
Add github workflow to ensure Rails can boot in production env
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed Oct 20, 2024
1 parent 6d85153 commit 83787f8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,40 @@ jobs:
name: assets
path: public
retention-days: 1

boot:
name: Linters
runs-on: ubuntu-latest
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_PRODUCTION_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm

- name: Node version
run: |
node --version
- name: Install packages
run: |
npm ci
- name: Start Rails server in the background
run: |
bundle exec puma -b http://127.0.0.1:3001 -e production &
sleep 10
- name: Make sure the server is running
run: |
bin/up http://127.0.0.1:3001/up
13 changes: 13 additions & 0 deletions bin/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

require "uri"
require "net/http"

url = ARGV[0] || "http://localhost:3000/up"

uri = URI(url)
res = Net::HTTP.get_response(uri)

puts "Request to #{url} returned #{res.code}"

exit 1 unless res.is_a?(Net::HTTPSuccess)
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
config.force_ssl = ENV.fetch("RAILS_FORCE_SSL", "true") == "true"

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new($stdout)
Expand Down

0 comments on commit 83787f8

Please sign in to comment.