Skip to content

Commit

Permalink
Deploy with bunny.net
Browse files Browse the repository at this point in the history
  • Loading branch information
TibiNonEst committed Nov 20, 2024
1 parent 1f4c336 commit c7ac5eb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deploy.yml
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"
16 changes: 16 additions & 0 deletions main.ts
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);
});

0 comments on commit c7ac5eb

Please sign in to comment.