elixirschool / school_house

The new era of Elixir School now powered by @phoenixframework
https://elixirschool.com/
Apache License 2.0
155 stars 49 forks source link

Fix Review App URL Configuration #133

Closed kinson closed 3 years ago

kinson commented 3 years ago

Overview

The Problem

Right now review apps don't set the correct hostname to be used when the sitemap or rss feed is generated - this makes it difficult to validate changes targeted at Rocket Validator issues. It also prevents the conferences live view from working because the socket connection is refused from school-house-pr-xxx.herokuapp.com -> beta.elixirschool.com (which is what is set for the host url property of SchoolHouseWeb.Endpoint).

[One] Solution

I finally gave up on trying to generate the sitemap with the HEROKU_APP_NAME environment variable when the docker image is built.

Instead, this solution generates the rss feed and sitemap when the app is deployed because we cannot deduce the review app URL until then (using the same HEROKU_APP_NAME environment variable).

While I did tweak the mix tasks to generate the rss feed and sitemap, I left the actual implementation as mix tasks so they can be still be run with mix school_house.gen.rss and mix school_house.gen.sitemap.

The biggest piece of this puzzle was adding a SchoolHouse.Release module to load the application and then generate the sitemap and rss feed. This was taken directly from the Elixir/Phoenix documentation for running tasks when an app is deployed.

Results

The correct URL is now used in the rss feed and sitemap xml files. For example, here are those pages on the review app the corresponds to this pr:

The conferences live view page now loads and connects to the websocket correctly: https://school-house-pr-133.herokuapp.com/en/conferences