Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
required: true
default: development
type: environment
client-ref:
description: "Client branch or tag"
required: false
default: main
type: string

permissions:
id-token: write # This is required for requesting the JWT for OIDC
Expand All @@ -30,7 +35,34 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Checkout code
uses: actions/checkout@v6
with:
repository: graasp/client
ref: ${{ inputs.client-ref || 'main' }}
path: client

- name: Install Mise
uses: jdx/mise-action@v3

- name: build client
run: cd client && mise run build && cp -r dist ../priv/static/client
env:
VITE_VERSION: ${{ inputs.version || github.sha }}
VITE_GRAASP_API_HOST: ${{ vars.VITE_GRAASP_API_HOST }}
VITE_GRAASP_WS_HOST: ${{ vars.VITE_GRAASP_WS_HOST }}
VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }}
VITE_SENTRY_ENV: ${{ inputs.environment || 'development' }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
VITE_SHOW_NOTIFICATIONS: true
VITE_UMAMI_WEBSITE_ID: ${{ secrets.VITE_UMAMI_WEBSITE_ID }}
VITE_UMAMI_HOST: ${{ vars.VITE_UMAMI_HOST }}
VITE_RECAPTCHA: ${{ secrets.VITE_RECAPTCHA_SITE_KEY }}
VITE_GRAASP_H5P_INTEGRATION_URL: ${{ vars.VITE_GRAASP_H5P_INTEGRATION_URL }}
VITE_GRAASP_REDIRECTION_HOST: ${{ vars.VITE_GRAASP_REDIRECTION_HOST }}
shell: bash

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ npm-debug.log
# PLT caches
/priv/plts/*.plt
/priv/plts/*.plt.hash

# client SPA artifacts
/priv/static/client
Empty file added lib/admin/docs.ex
Empty file.
2 changes: 1 addition & 1 deletion lib/admin_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule AdminWeb do
"""

def static_paths,
do: ~w(assets fonts images icons favicon.ico favicons robots.txt)
do: ~w(assets fonts images icons client favicon.ico favicons robots.txt)

def router do
quote do
Expand Down
19 changes: 19 additions & 0 deletions lib/admin_web/controllers/client_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule AdminWeb.ClientController do
use AdminWeb, :controller

def index(conn, _params) do
conn
|> put_resp_content_type("text/html")
|> send_resp(200, render_react_app())
end

# Serve the index.html file as-is and let React
# take care of the rendering and client-side rounting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# take care of the rendering and client-side rounting.
# take care of the rendering and client-side routing.

#
# Potential improvement: Cache the file contents here
# in an ETS table so we don't read from the disk for every request.
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an issue?

defp render_react_app do
Application.app_dir(:admin, "priv/static/client/index.html")
|> File.read!()
end
end
Empty file.
4 changes: 0 additions & 4 deletions lib/admin_web/controllers/redirection_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@ defmodule AdminWeb.RedirectionController do
def library(conn, _params) do
redirect(conn, external: Application.get_env(:admin, :library_origin))
end

def login(conn, _params) do
redirect(conn, external: "#{Application.get_env(:admin, :client_origin)}/auth/login")
end
end
10 changes: 9 additions & 1 deletion lib/admin_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ defmodule AdminWeb.Router do
delete "/locale", LandingController, :remove_locale

generate_localized_routes()

get "/home", ClientController, :index
get "/published", ClientController, :index
get "/recycled", ClientController, :index
get "/account/*path", ClientController, :index
get "/auth/*path", ClientController, :index
get "/builder/*path", ClientController, :index
get "/player/*path", ClientController, :index

# redirections for now
get "/library", RedirectionController, :library
get "/auth/login", RedirectionController, :login
end

scope "/admin", AdminWeb do
Expand Down
Loading