Skip to content

Merge pull request #17 from 7Sageer/test #53

Merge pull request #17 from 7Sageer/test

Merge pull request #17 from 7Sageer/test #53

Workflow file for this run

name: Deploy Worker
on:
workflow_dispatch:
repository_dispatch:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '21'
- name: Install dependencies and wrangler
run: |
npm install
npm install -g wrangler
- name: Check and Create KV Namespace
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
KV_NAMESPACE="SUBLINK_KV"
KV_ID=$(wrangler kv:namespace list | jq -r '.[] | select(.title == "sublink-worker-'$KV_NAMESPACE'") | .id')
if [ -z "$KV_ID" ]; then
KV_ID=$(wrangler kv:namespace create "$KV_NAMESPACE" | jq -r '.id')
fi
echo "KV_ID=$KV_ID" >> $GITHUB_ENV
- name: Update wrangler.toml
run: sed -i 's/id = "[^"]*"/id = "'$KV_ID'"/' wrangler.toml
- name: Deploy to Cloudflare Workers
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
- name: Display deployment logs
if: failure()
run: wrangler tail --format pretty