diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b236df64..cd625c87 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,8 +1,11 @@ name: Deploy to AWS on: - push: + workflow_run: + workflows: ["Pre-Deploy Status Check"] branches: [main] + types: + - completed permissions: id-token: write @@ -12,6 +15,7 @@ jobs: deploy: name: Build, Push to ECR, and Deploy to Fargate runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success'}} steps: - name: Checkout Code diff --git a/.github/workflows/pre_deploy_status_check.yml b/.github/workflows/pre_deploy_status_check.yml new file mode 100644 index 00000000..59949c39 --- /dev/null +++ b/.github/workflows/pre_deploy_status_check.yml @@ -0,0 +1,24 @@ +name: Pre-Deploy Status Check + +on: + workflow_run: + workflows: ["Ruby", "Node.js CI", "Cypress Tests"] + branches: [main] + types: + - completed + +jobs: + check-statuses: + runs-on: ubuntu-latest + steps: + - name: Check Workflow Statuses + run: | + required_workflows=("Ruby" "Node.js CI" "Cypress Tests") + for workflow in "${required_workflows[@]}"; do + status=$(gh run list --workflow "$workflow" --branch main --json conclusion -q '.[0].conclusion') + echo "$workflow: $status" + if [[ "$status" != "success" ]]; then + echo "Workflow $workflow did not succeed. Aborting deployment." + exit 1 + fi + done diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c8bdac56..3aa8c657 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,5 +1,7 @@ class PagesController < ActionController::Base def index + raise ActionController::RoutingError.new("Not Found") unless route_valid? + raw_games = Game.current.includes(:host, :current_player, :users, :winner, :cloned_from_game) redis_data = JSON.parse(REDIS.get("users_observing_games")) @@ -21,4 +23,10 @@ def robots format.text { render plain: rules } end end + + private + + def route_valid? + %w[register sign_in about rules game finished_games users games cloned_games import_game forgot_password reset_password rankings].any? { |path| params[:path]&.include?(path) } || !params[:path] + end end diff --git a/config/database.yml b/config/database.yml index e6ccddab..b8bb0c98 100644 --- a/config/database.yml +++ b/config/database.yml @@ -25,7 +25,7 @@ default: &default development: <<: *default database: postgres - host: db + host: localhost # The specified database role being used to connect to postgres. # To create additional roles in postgres see `$ createuser --help`. diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index 2e88afe9..bc865e4f 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -1,5 +1,5 @@ require "redis" -REDIS = Redis.new(url: ENV["REDIS_URL"] || "redis://redis:6379/0") +REDIS = Redis.new(url: ENV["REDIS_URL"] || "redis://localhost:6379/0") REDIS.set("online_users", [].to_json) REDIS.set("users_observing_games", {}.to_json) diff --git a/config/routes.rb b/config/routes.rb index 51db029d..2f7d6fc4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,7 +30,7 @@ root "pages#index", as: :pages_index get "/robots.txt", to: "pages#robots" - get "*path", to: "pages#index", format: false + get "*path", to: "pages#index", constraints: ->(req) { req.format.html? }, format: false if Rails.env.test? namespace :cypress do