-
Notifications
You must be signed in to change notification settings - Fork 9
Migrate site to Cloudflare Workers and GitHub Actions #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Deploying docs with
|
Latest commit: |
b2f8906
|
Status: | ✅ Deploy successful! |
Preview URL: | https://0bbf833a.docs-dog.pages.dev |
Branch Preview URL: | https://copilot-fix-492.docs-dog.pages.dev |
Co-authored-by: ppiegaze <[email protected]>
Co-authored-by: ppiegaze <[email protected]>
Co-authored-by: ppiegaze <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the unionai-docs project from Cloudflare Pages to a GitHub Actions-based build system with Cloudflare Workers deployment. The migration enables better control over the build process while maintaining Cloudflare hosting, and introduces advanced multi-version deployment capabilities.
Key changes implemented:
- Multi-version combined builds that automatically build and deploy both v1 and v2 versions when either branch is updated
- Enhanced PR preview system with automatic comments containing direct links to all documentation variants
- Robust CI-friendly build process with graceful handling of missing submodules and dependencies
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
.github/workflows/build-and-deploy.yml |
Production deployment workflow for main/v1 branches |
.github/workflows/pr-preview.yml |
PR preview workflow with automatic commenting |
.github/workflows/cleanup-pr.yml |
Cleanup workflow for removing PR preview environments |
scripts/build-combined.sh |
Main build orchestration script for multi-version builds |
scripts/run_hugo_ci.sh |
CI-friendly Hugo wrapper that handles warnings gracefully |
worker.js |
Cloudflare Worker for routing and redirects |
wrangler.toml |
Cloudflare Workers deployment configuration |
Makefile |
Added CI-friendly build targets |
MIGRATION.md |
Comprehensive setup and migration instructions |
.github/README.md |
Documentation for CI/CD architecture and workflows |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if (!url.pathname.startsWith('/docs/')) { | ||
newUrl.pathname = '/docs/flyte' + url.pathname; | ||
} | ||
return Response.redirect(newUrl.toString(), 301); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The legacy domain redirect logic (lines 29-35) appears to be handling docs.flyte.org redirects but may conflict with the main routing logic. Consider adding a comment explaining the expected URL patterns and ensure this doesn't interfere with normal routing.
Copilot uses AI. Check for mistakes.
log "Switching to $OTHER_BRANCH for $OTHER_VERSION" | ||
git checkout "$OTHER_BRANCH" | ||
|
||
log "Building other version ($OTHER_VERSION) from $OTHER_BRANCH" | ||
make dist-ci | ||
|
||
# Switch back to PR branch | ||
git checkout "$HEAD_REF" || git checkout - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback git checkout -
may not reliably return to the intended PR branch if $HEAD_REF
checkout fails. Consider storing the current commit hash before branch switching and checking out that specific commit as a more reliable fallback.
log "Switching to $OTHER_BRANCH for $OTHER_VERSION" | |
git checkout "$OTHER_BRANCH" | |
log "Building other version ($OTHER_VERSION) from $OTHER_BRANCH" | |
make dist-ci | |
# Switch back to PR branch | |
git checkout "$HEAD_REF" || git checkout - | |
# Store current commit hash before switching branches | |
ORIGINAL_COMMIT="$(git rev-parse HEAD)" | |
log "Switching to $OTHER_BRANCH for $OTHER_VERSION" | |
git checkout "$OTHER_BRANCH" | |
log "Building other version ($OTHER_VERSION) from $OTHER_BRANCH" | |
make dist-ci | |
# Switch back to PR branch, or fallback to original commit hash | |
git checkout "$HEAD_REF" || git checkout "$ORIGINAL_COMMIT" |
Copilot uses AI. Check for mistakes.
# Try to delete the preview deployment | ||
# This might fail if the deployment doesn't exist, which is OK | ||
wrangler pages deployment list --project-name=unionai-docs --compatibility-date=2024-01-01 | \ | ||
grep "${{ steps.preview.outputs.preview_name }}" | \ | ||
head -1 | \ | ||
awk '{print $1}' | \ | ||
xargs -r wrangler pages deployment delete --project-name=unionai-docs || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pipeline for deleting preview deployments is complex and fragile. The grep
pattern could match partial strings, and the awk
command assumes a specific output format. Consider using wrangler pages deployment delete
with more specific parameters or JSON output parsing for more reliable cleanup.
# Try to delete the preview deployment | |
# This might fail if the deployment doesn't exist, which is OK | |
wrangler pages deployment list --project-name=unionai-docs --compatibility-date=2024-01-01 | \ | |
grep "${{ steps.preview.outputs.preview_name }}" | \ | |
head -1 | \ | |
awk '{print $1}' | \ | |
xargs -r wrangler pages deployment delete --project-name=unionai-docs || true | |
# Try to delete the preview deployment(s) using robust JSON parsing | |
# This might fail if the deployment doesn't exist, which is OK | |
DEPLOYMENT_IDS=$(wrangler pages deployment list --project-name=unionai-docs --compatibility-date=2024-01-01 --output json | \ | |
jq -r --arg env "${{ steps.preview.outputs.preview_name }}" '.[] | select(.environment==$env) | .id') | |
for id in $DEPLOYMENT_IDS; do | |
wrangler pages deployment delete --project-name=unionai-docs "$id" || true | |
done |
Copilot uses AI. Check for mistakes.
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: production-build-${{ steps.versions.outputs.current_version }}-${{ github.sha }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The artifact name references steps.versions.outputs.current_version
but there is no step with id 'versions' defined in this workflow. This will result in an empty string in the artifact name.
Copilot uses AI. Check for mistakes.
This PR implements a complete migration of the unionai-docs project from Cloudflare Pages to a GitHub Actions build system with Cloudflare Pages deployment.
Migration Overview
The current setup builds and hosts the site on Cloudflare Pages. This migration moves all building to GitHub Actions while keeping Cloudflare for hosting, providing better control over the build process and enabling advanced deployment strategies.
Key Features Implemented
Multi-Version Combined Builds
main
orv1
branch is updated, both versions are built and combined into a single deploymentmain
) and v1 (fromv1
branch) under/docs/v2/
and/docs/v1/
respectivelyAdvanced PR Previews
Robust Build Process
Technical Implementation
The migration includes three main workflows:
build-and-deploy.yml
): Triggered on pushes tomain
orv1
, builds both versions and deploys combined sitepr-preview.yml
): Creates preview deployments with PR timeline commentscleanup-pr.yml
): Removes preview environments when PRs closeA unified build script (
scripts/build-combined.sh
) orchestrates the complex multi-branch building and combining logic, while a CI-friendly Hugo wrapper (scripts/run_hugo_ci.sh
) ensures builds succeed even with missing external dependencies.Site Structure
The deployed site maintains the existing URL structure while supporting both versions:
Setup Requirements
The migration requires configuring two Cloudflare secrets (
CLOUDFLARE_API_TOKEN
andCLOUDFLARE_ACCOUNT_ID
) and creating a Cloudflare Pages project. Complete setup instructions are provided inMIGRATION.md
.Fixes #492.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)github.com (HTTP Only)
/usr/bin/ssh -o SendEnv=GIT_PROTOCOL [email protected] git-upload-pack 'unionai/unionai-examples'
(packet block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.