Skip to content

Commit 2f1a62e

Browse files
Route social link preview fetches through Cloudflare worker (#18)
- add a social-link-preview Cloudflare Worker that fetches page HTML, extracts metadata, and returns guideline results - rework the social link preview frontend to call the worker API and render the returned reports - document the new worker and hook it into the deployment workflow ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_6915ea5572788325b434762c9a96d607)
1 parent 4319066 commit 2f1a62e

6 files changed

Lines changed: 555 additions & 359 deletions

File tree

.github/workflows/deploy-cloudflare-workers.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
pull-requests: read
1717
outputs:
1818
gumroad_products: ${{ steps.filter.outputs.gumroad-products }}
19+
social_link_preview: ${{ steps.filter.outputs.social-link-preview }}
1920
# If I add more filters below, I need to “export them” here.
2021
steps:
2122
- uses: actions/checkout@v4
@@ -27,6 +28,8 @@ jobs:
2728
filters: |
2829
gumroad-products:
2930
- 'cloudflare-workers/gumroad-products/**'
31+
social-link-preview:
32+
- 'cloudflare-workers/social-link-preview/**'
3033
# I can add more filters here and access them separately.
3134

3235
deploy-gumroad-products:
@@ -53,3 +56,28 @@ jobs:
5356
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5457
run: |
5558
wrangler deploy --env production
59+
60+
deploy-social-link-preview:
61+
name: Deploy Social Link Preview Worker
62+
runs-on: ubuntu-latest
63+
needs: changes
64+
if: ${{ github.event_name == 'workflow_dispatch' || needs.changes.outputs.social_link_preview == 'true' }}
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: '20'
73+
74+
- name: Install Wrangler
75+
run: npm install -g wrangler
76+
77+
- name: Deploy to Cloudflare Workers
78+
working-directory: cloudflare-workers/social-link-preview
79+
env:
80+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
81+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
82+
run: |
83+
wrangler deploy --env production

cloudflare-workers/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Each worker lives in its own subdirectory with:
1414
- **Location**: `cloudflare-workers/gumroad-products/`
1515
- **Purpose**: Fetch products from a Gumroad user profile page
1616

17+
### social-link-preview
18+
- **Location**: `cloudflare-workers/social-link-preview/`
19+
- **Purpose**: Fetch a URL server-side, extract metadata, and return link preview reports for the frontend tool
20+
1721
## Setup Instructions
1822

1923
### 1. Install Wrangler CLI (Optional - for local development)

0 commit comments

Comments
 (0)