Introduces adapters for Vercel, Netlify Edge, Deno Deploy, and Cloudflare Pages, each with platform-specific entry points and configuration files. Adds a GitHub Actions CI workflow for linting, type checking, and testing. Updates lint scripts to include adapters, improves type annotations in src/index.js, and fixes a type assertion in security tests.
160 lines
5.0 KiB
YAML
160 lines
5.0 KiB
YAML
name: Sync to Pages and Functions
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- "**.md"
|
|
- "LICENSE"
|
|
- ".gitignore"
|
|
- ".editorconfig"
|
|
- ".vscode/**"
|
|
- "docs/**"
|
|
- ".prettierrc*"
|
|
- ".eslintrc*"
|
|
- ".github/ISSUE_TEMPLATE/**"
|
|
- ".github/PULL_REQUEST_TEMPLATE/**"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
convert-and-sync-pages:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout main branch
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Setup adapter files
|
|
run: |
|
|
mkdir -p /tmp/pages-conversion
|
|
cp -r adapters/pages/* /tmp/pages-conversion/
|
|
|
|
- name: Copy source code files
|
|
run: |
|
|
cp -r src /tmp/pages-conversion/
|
|
cp package.json /tmp/pages-conversion/
|
|
cp package-lock.json /tmp/pages-conversion/ 2>/dev/null || true
|
|
cp LICENSE /tmp/pages-conversion/
|
|
|
|
- name: Export handleRequest from src/index.js
|
|
run: |
|
|
cd /tmp/pages-conversion
|
|
# Add export statement before the default export at the end of the file
|
|
sed -i '/^export default {$/i\
|
|
export { handleRequest };' src/index.js
|
|
|
|
- name: Update package.json for Pages
|
|
run: |
|
|
cd /tmp/pages-conversion
|
|
# Update deployment commands to use Pages
|
|
cat package.json | \
|
|
sed 's/"deploy": "wrangler deploy"/"deploy": "wrangler pages deploy ."/' | \
|
|
sed 's/"start": "wrangler dev"/"start": "wrangler pages dev ."/' \
|
|
> package.json.tmp && mv package.json.tmp package.json
|
|
|
|
- name: Initialize pages branch
|
|
run: |
|
|
cd /tmp/pages-conversion
|
|
git init
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b pages
|
|
git add .
|
|
git commit -m "Convert Workers to Pages
|
|
|
|
Auto-converted from main branch commit ${{ github.sha }}
|
|
|
|
Runtime files only (documentation, tests, and dev configs excluded)."
|
|
|
|
- name: Force push to pages branch
|
|
run: |
|
|
cd /tmp/pages-conversion
|
|
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
|
|
git push -f origin pages
|
|
|
|
- name: Clean up
|
|
if: always()
|
|
run: |
|
|
rm -rf /tmp/pages-conversion
|
|
|
|
convert-and-sync-functions:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout main branch
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
- name: Setup adapter files
|
|
run: |
|
|
mkdir -p /tmp/functions-conversion
|
|
# Copy all content from adapters/functions excluding package.json first
|
|
cp -r adapters/functions/* /tmp/functions-conversion/
|
|
# Copy the specific package.json for functions (overwriting if needed, but we do it later anyway)
|
|
|
|
- name: Copy source code files
|
|
run: |
|
|
# Copy only runtime-required files
|
|
cp -r src /tmp/functions-conversion/
|
|
# Note: We do NOT copy the root package.json here as we use the one from adapters/functions
|
|
cp package-lock.json /tmp/functions-conversion/ 2>/dev/null || true
|
|
cp LICENSE /tmp/functions-conversion/
|
|
|
|
- name: Export handleRequest from src/index.js
|
|
run: |
|
|
cd /tmp/functions-conversion
|
|
# Add export statement before the default export at the end of the file
|
|
sed -i '/^export default {$/i\
|
|
export { handleRequest };' src/index.js
|
|
|
|
- name: Initialize functions branch
|
|
run: |
|
|
cd /tmp/functions-conversion
|
|
git init
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git checkout -b functions
|
|
git add .
|
|
git commit -m "Convert Workers to Functions
|
|
|
|
Auto-converted from main branch commit ${{ github.sha }}
|
|
|
|
Runtime files only (documentation, tests, and dev configs excluded)."
|
|
|
|
- name: Force push to functions branch
|
|
run: |
|
|
cd /tmp/functions-conversion
|
|
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
|
|
git push -f origin functions
|
|
|
|
- name: Clean up
|
|
if: always()
|
|
run: |
|
|
rm -rf /tmp/functions-conversion
|