Skip to content

Commit c822801

Browse files
authored
Merge pull request #1 from NCUAppTeam/1989ONCE-patch-1
actions modify for test
2 parents 2920769 + 0943b5f commit c822801

File tree

6 files changed

+160
-5
lines changed

6 files changed

+160
-5
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Deploy Vite with GitHub Pages dependencies preinstalled
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["login-test"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
# Build job
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Setup Pages
31+
uses: actions/configure-pages@v5
32+
33+
# Set up .env file with GitHub secrets
34+
- name: Set up .env with secrets
35+
run: |
36+
echo "VITE_SUPABASE_URL=${{ secrets.VITE_SUPABASE_URL }}" > .env
37+
echo "VITE_SUPABASE_ANON_KEY=${{ secrets.VITE_SUPABASE_ANON_KEY }}" >> .env
38+
echo "VITE_NCU_PORTAL_CLIENT_ID=${{ secrets.VITE_NCU_PORTAL_CLIENT_ID }}" >> .env
39+
echo "VITE_NCU_PORTAL_SECRET=${{ secrets.VITE_NCU_PORTAL_SECRET }}" >> .env
40+
env:
41+
VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
42+
VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}
43+
VITE_NCU_PORTAL_CLIENT_ID: ${{ secrets.VITE_NCU_PORTAL_CLIENT_ID }}
44+
VITE_NCU_PORTAL_SECRET: ${{ secrets.VITE_NCU_PORTAL_SECRET }}
45+
46+
47+
48+
# Debug - Verify .env file creation
49+
- name: Debug - Verify .env file creation
50+
run: |
51+
if [ -f .env ]; then
52+
echo ".env file exists!"
53+
cat .env
54+
else
55+
echo ".env file does not exist!"
56+
fi
57+
58+
59+
- name: Build with Vite
60+
run: npm ci && npm run build
61+
- name: Upload artifact
62+
uses: actions/upload-pages-artifact@v3
63+
with:
64+
path: dist/
65+
# Deployment job
66+
deploy:
67+
environment:
68+
name: github-pages
69+
url: ${{ steps.deployment.outputs.page_url }}
70+
runs-on: ubuntu-latest
71+
needs: build
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4

404.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Single Page Apps for GitHub Pages</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License
9+
// https://github.com/rafgraph/spa-github-pages
10+
// This script takes the current url and converts the path and query
11+
// string into just a query string, and then redirects the browser
12+
// to the new url with only a query string and hash fragment,
13+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
14+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
15+
// Note: this 404.html file must be at least 512 bytes for it to work
16+
// with Internet Explorer (it is currently > 512 bytes)
17+
18+
// If you're creating a Project Pages site and NOT using a custom domain,
19+
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
20+
// This way the code will only replace the route part of the path, and not
21+
// the real directory in which the app resides, for example:
22+
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
23+
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
24+
// Otherwise, leave pathSegmentsToKeep as 0.
25+
var pathSegmentsToKeep = 0;
26+
27+
var l = window.location;
28+
l.replace(
29+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
30+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
31+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
32+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
33+
l.hash
34+
);
35+
36+
</script>
37+
</head>
38+
<body>
39+
</body>
40+
</html>

index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@
55

66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>NCU-APP</title>
8+
9+
<!-- Start Single Page Apps for GitHub Pages -->
10+
<script type="text/javascript">
11+
// Single Page Apps for GitHub Pages
12+
// MIT License
13+
// https://github.com/rafgraph/spa-github-pages
14+
// This script checks to see if a redirect is present in the query string,
15+
// converts it back into the correct url and adds it to the
16+
// browser's history using window.history.replaceState(...),
17+
// which won't cause the browser to attempt to load the new url.
18+
// When the single page app is loaded further down in this file,
19+
// the correct url will be waiting in the browser's history for
20+
// the single page app to route accordingly.
21+
22+
(function (l) {
23+
if (l.search[1] === '/') {
24+
var decoded = l.search.slice(1).split('&').map(function (s) {
25+
return s.replace(/~and~/g, '&')
26+
}).join('?');
27+
window.history.replaceState(null, null,
28+
l.pathname.slice(0, -1) + decoded + l.hash
29+
);
30+
}
31+
}(window.location))
32+
</script>
33+
<!-- End Single Page Apps for GitHub Pages -->
34+
835
</head>
936
<body>
1037
<div id="root"></div>

src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { routeTree } from './routeTree.gen'
1010
const router = createRouter({
1111
routeTree,
1212
defaultPreload: 'intent',
13+
basepath: '/',
1314
})
1415

1516
// Register the router instance for type safety

src/utils/supabase.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { createClient } from '@supabase/supabase-js'
22
import { Database } from './database.types'
33

44
// supabase client for interacting with the database
5-
export const supabase = createClient<Database>(
6-
import.meta.env.VITE_SUPABASE_URL,
7-
import.meta.env.VITE_SUPABASE_ANON_KEY,
8-
)
5+
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
6+
const supabaseKey = import.meta.env.VITE_SUPABASE_ANON_KEY
7+
8+
if (!supabaseUrl || !supabaseKey) {
9+
console.error("Supabase URL or Key is missing. Check your environment variables.")
10+
}
11+
12+
export const supabase = createClient<Database>(supabaseUrl, supabaseKey)

vite.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ export default defineConfig({
3838
},
3939
})
4040
],
41-
})
41+
build: {
42+
rollupOptions: {
43+
input: {
44+
main: './index.html',
45+
spa: './404.html', // Include 404.html in the build input
46+
},
47+
},
48+
},
49+
});

0 commit comments

Comments
 (0)