- Add ci.yml with lint, test, and typecheck jobs - Update workers.yml to trigger on CI workflow completion - Update sync.yml to trigger on CI workflow completion - Update image.yml to trigger on CI workflow completion - Fix pages-eo.yml secret name to match README (EDGEONE_PAGES_API_TOKEN) Deployment workflows now only run after CI passes, preventing broken code from being deployed to any platform.
154 lines
5.0 KiB
YAML
154 lines
5.0 KiB
YAML
name: Sync to Pages and Functions
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["CI"]
|
|
types:
|
|
- completed
|
|
branches:
|
|
- main
|
|
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
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
|
|
|
|
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
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
|
|
|
|
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
|