From 3e159ac82b0f5e1fc7d111e582cd16d391a4a68a Mon Sep 17 00:00:00 2001 From: alyssadev Date: Sun, 17 Sep 2023 06:34:37 +1000 Subject: [PATCH] added deploy button and github action deploy --- .github/workflows/main.yml | 21 +++++++++++++++++++++ README.md | 2 ++ src/index.js | 2 +- wrangler.toml | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2827788 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,21 @@ +on: + repository_dispatch: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + name: Deploy + steps: + - uses: actions/checkout@master + - name: Publish + uses: cloudflare/wrangler-action@1.3.0 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + secrets: | + AUTH_KEY + env: + CF_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} + AUTH_KEY: ${{ secrets.AUTH_KEY }} diff --git a/README.md b/README.md index 790a38f..b9c0a82 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ linkie A simple url shortener. Largely adapting [VandyHacks/vhl.ink](https://github.com/VandyHacks/vhl.ink) with the aim of providing a more ptpb-like experience (i.e the fewest keystrokes from a cli possible while still being reasonably secure for private use) +[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/alyssadev/linkie) + Deploying --------- diff --git a/src/index.js b/src/index.js index d1f521b..ec9da17 100644 --- a/src/index.js +++ b/src/index.js @@ -64,7 +64,7 @@ async function get(host,path,auth) { keys.forEach(element => paths += `${element.name}\n`); return new Response(paths,{status:200}) } - if (!path) return Response.redirect("https://aly-smith.carrd.co",301) + if (!path) return Response.redirect(REDIR_URL,301) path = path.toLowerCase() const dest = await KV.get(path) if (dest) return Response.redirect(dest, 302) diff --git a/wrangler.toml b/wrangler.toml index 5a449b3..64ba432 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -4,3 +4,5 @@ compatibility_date = "2023-09-14" kv_namespaces = [ { binding = "KV", id = "7214e776a3da4ccd9f9fe5b6c3d3f781" } ] +[vars] +REDIR_URL = "https://aly-smith.carrd.co/"