diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f5a7aff --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Deploy when pushing on main + +on: + push: + branches: + - "main" + +jobs: + publish: + runs-on: ubuntu-latest + + name: "Deploy site" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + + - name: Install dependencies + run: bun install + + - name: Build site + run: bun run build + + - name: Upload files + uses: djang0dev/bunnynet-storage-deployer@v0.0.2 + with: + upload: true + remove: true + storageName: ${{ secrets.BUNNY_STORAGE_NAME }} + storagePassword: ${{ secrets.BUNNY_STORAGE_PASSWORD }} + destination: "tibs.gay/" + sourcePattern: "./dist/**/*.*" + apiKey: ${{ secrets.BUNNY_API_KEY }} + purgePullZone: true + pullZoneId: ${{ secrets.BUNNY_PULL_ZONE_ID }} + + - name: Deploy script + uses: BunnyWay/actions/deploy-script@main + with: + script_id: ${{ secrets.BUNNY_SCRIPT_ID }} + deploy_key: ${{ secrets.BUNNY_DEPLOY_KEY }} + file: "script.ts" \ No newline at end of file diff --git a/script.ts b/script.ts new file mode 100644 index 0000000..b0ca854 --- /dev/null +++ b/script.ts @@ -0,0 +1,16 @@ +import * as BunnySDK from "https://esm.sh/@bunny.net/edgescript-sdk@0.10.0"; + +BunnySDK.net.http.serve(async (request: Request): Response | Promise => { + const url = new URL(request.url); + let path = url.pathname; + + if (path == "/") { + path = "/index.html"; + } + + if (path.startsWith("/_astro") || path == "/index.html") { + return fetch("https://tibs-sites.b-cdn.net/tibs.gay" + path); + } + + return Response.redirect("/", 308); +});