From 1b5a306879b379386fbcb1df0b7fd5b98bb18f65 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 14 Sep 2023 19:27:34 +0200 Subject: [PATCH] cloudflare deploy button --- .github/workflows/cloudflare.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/linting.yml | 2 +- README.md | 9 +++++++-- package.json | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/cloudflare.yml diff --git a/.github/workflows/cloudflare.yml b/.github/workflows/cloudflare.yml new file mode 100644 index 0000000..09ba7af --- /dev/null +++ b/.github/workflows/cloudflare.yml @@ -0,0 +1,32 @@ +name: Deploy Worker + +# this action is for the "deploy to cloudflare" button +# repository_dispatch is triggered by CF +# secrets should also be made by CF + +on: ["repository_dispatch"] + +jobs: + deploy: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Install npm packages + run: npm install + + - name: Build Project + run: npm run build:cloudflare + + - name: Build & Deploy Worker + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index ffb3287..5c41559 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - + - name: Install Node.js uses: actions/setup-node@v3 with: diff --git a/README.md b/README.md index 68e7ceb..4bdba7d 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,18 @@ Simple reverse proxy to bypass CORS, used by [movie-web](https://movie-web.app). -features: +[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/YOURUSERNAME/YOURREPO) + +--- + +### features: - Deployable on many platforms - thanks to nitro - header rewrites - read and write protected headers - bypass CORS - always allows browser to send requests through it -supported platforms: +### supported platforms: - cloudflare workers + - AWS lambda - nodejs ## Todos: diff --git a/package.json b/package.json index b20a234..8b55d2c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "prepare": "nitropack prepare", "dev": "nitropack dev", "build": "nitropack build", + "build:cloudflare": "NITRO_PRESET=cloudflare npm run build", + "build:aws": "NITRO_PRESET=aws_lambda npm run build", + "build:node": "NITRO_PRESET=node-server npm run build", "start": "node .output/server/index.mjs", "lint": "eslint --ext .js src/", "lint:fix": "eslint --fix --ext .js src/"