From 83787f820e27d8041dc8ac92226f986daed98930 Mon Sep 17 00:00:00 2001 From: Ross Kaffenberger Date: Sun, 20 Oct 2024 09:40:06 -0400 Subject: [PATCH] Add github workflow to ensure Rails can boot in production env --- .github/workflows/verify.yml | 37 +++++++++++++++++++++++++++++++ bin/up | 13 +++++++++++ config/environments/production.rb | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 bin/up diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 06ca4048..d2675a53 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -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 diff --git a/bin/up b/bin/up new file mode 100755 index 00000000..90f6c7bb --- /dev/null +++ b/bin/up @@ -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) diff --git a/config/environments/production.rb b/config/environments/production.rb index b39c9b28..6b38f20a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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)