-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f4c336
commit c7ac5eb
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Deploy when pushing on main | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
name: 'Build and deploy script' | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setuo Bun | ||
uses: oven-sh/setup-bun@v2 | ||
|
||
- name: Install dependencies | ||
run: bun install | ||
|
||
- name: Built site | ||
run: bun run build | ||
|
||
- name: Deploy Script to Bunny Edge Scripting | ||
uses: BunnyWay/actions/deploy-script@main | ||
with: | ||
script_id: ${{ secrets.SCRIPT_ID }} | ||
deploy_key: ${{ secrets.DEPLOY_KEY }} | ||
file: "main.ts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as BunnySDK from "https://esm.sh/@bunny.net/[email protected]"; | ||
|
||
BunnySDK.net.http.serve(async (request: Request): Response | Promise<Response> => { | ||
const url = new URL(request.url); | ||
let path = url.pathname; | ||
|
||
if (path == "/") { | ||
path = "/index.html"; | ||
} | ||
|
||
if (path.startsWith("/_astro/") || path == "/index.html") { | ||
return new Response(Deno.readTextFile("dist" + path), { headers: { "content-type": "text/html" }}); | ||
} | ||
|
||
return Response.redirect("/", 308); | ||
}); |