From 4acf9ae0a1c8469209996d1018ca13c48d301e4b Mon Sep 17 00:00:00 2001
From: Florian PAUL <florian.paul@amadeus.com>
Date: Thu, 28 Sep 2023 15:59:56 +0200
Subject: [PATCH] feat: deploy showcase in github pages

---
 .github/workflows/deploy-showcase.yml       | 46 +++++++++++++++++++++
 apps/showcase/src/app/app-routing.module.ts |  2 +-
 apps/showcase/src/index.html                |  2 +-
 3 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 .github/workflows/deploy-showcase.yml

diff --git a/.github/workflows/deploy-showcase.yml b/.github/workflows/deploy-showcase.yml
new file mode 100644
index 0000000000..24c12b8e59
--- /dev/null
+++ b/.github/workflows/deploy-showcase.yml
@@ -0,0 +1,46 @@
+# Simple workflow for deploying static content to GitHub Pages
+name: Deploy static content to Pages
+
+on:
+  # Runs on pushes targeting the default branch
+  push:
+    branches: ["main"]
+
+  # Allows you to run this workflow manually from the Actions tab
+  workflow_dispatch:
+
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+  contents: read
+  pages: write
+  id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+  group: "pages"
+  cancel-in-progress: false
+
+jobs:
+  deploy:
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
+    runs-on: ubuntu-latest
+    env:
+      NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+      - uses: ./tools/github-actions/setup
+      - name: build
+        run: yarn nx build showcase
+      - name: Setup Pages
+        uses: actions/configure-pages@v3
+      - name: Upload artifact
+        uses: actions/upload-pages-artifact@v2
+        with:
+          path: './apps/showcase/dist'
+      - name: Deploy to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v2
diff --git a/apps/showcase/src/app/app-routing.module.ts b/apps/showcase/src/app/app-routing.module.ts
index 1191cb16ca..d72b923401 100644
--- a/apps/showcase/src/app/app-routing.module.ts
+++ b/apps/showcase/src/app/app-routing.module.ts
@@ -15,7 +15,7 @@ const appRoutes: Routes = [
 
 @NgModule({
   imports: [
-    RouterModule.forRoot(appRoutes, {scrollPositionRestoration: 'enabled'})
+    RouterModule.forRoot(appRoutes, {scrollPositionRestoration: 'enabled', useHash: true})
   ],
   exports: [RouterModule]
 })
diff --git a/apps/showcase/src/index.html b/apps/showcase/src/index.html
index bb9af77901..e38da6a27d 100644
--- a/apps/showcase/src/index.html
+++ b/apps/showcase/src/index.html
@@ -3,7 +3,7 @@
 <head>
   <meta charset="utf-8">
   <title>Otter Showcase</title>
-  <base href="/">
+  <base href="./">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="icon" href="favicon.svg">
 </head>