-
Notifications
You must be signed in to change notification settings - Fork 10
Add relay crawler worker and GitHub Actions workflows #318
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
Open
rabble
wants to merge
17
commits into
main
Choose a base branch
from
notification_worker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c1b646e
adding more files
rabble 1173e62
Merge remote-tracking branch 'origin' into notification_worker
rabble cb5771c
WIP: Save current notification worker changes before updating from main
rabble 6440dc2
Merge main into notification_worker branch, keeping worker files that…
rabble 32637e0
Fix: Remove EOF markers and fix TypeScript linting errors in worker f…
rabble a21b40f
feat: Add push notification permission system with smart prompting
rabble 72123d9
docs: Add VAPID key generation and documentation
rabble dbbc57b
Add relay crawler worker and GitHub Actions workflows
rabble 1cc5092
Add KV namespace IDs for relay crawler
rabble adaba25
Remove CPU limits for free plan compatibility
rabble 666a810
feat: add push notification worker with dev server and tests
NotThatKindOfDrLiz d94e8fc
chore: set real KV namespace IDs for deployment
NotThatKindOfDrLiz 385842d
fix: use only new_sqlite_classes for PushQueue migration
NotThatKindOfDrLiz 73c672f
fix: remove [limits] section for free plan deployment
NotThatKindOfDrLiz 4a39c23
fix: export PushQueue for Durable Object migration
NotThatKindOfDrLiz 06febef
feat: deploy push notification worker to production and add test script
NotThatKindOfDrLiz 819d395
fix: resolve merge conflicts in worker files and dependencies
NotThatKindOfDrLiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Frontend Environment Variables | ||
|
|
||
| # Worker URL for push notifications | ||
| VITE_WORKER_URL=https://your-worker-name.workers.dev | ||
|
|
||
| # VAPID public key for push notifications (generate with ./generate-vapid-keys.sh) | ||
| VITE_VAPID_PUBLIC_KEY=BN3XFrNV5EPXuBtW8gTOXZ8s1JzowUQZCPy2kyAiPvPq4x1zSwdZuEXpZrDYIvhW_bAOQdQoV_R7sI_9IK8Hbxg | ||
|
|
||
| # Optional: Custom relay URL (defaults to wss://relay.chorus.community/) | ||
| # VITE_RELAY_URL=wss://your-relay.com/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # GitHub Actions CI/CD Setup | ||
|
|
||
| This repository uses GitHub Actions for automated testing, building, and deployment to Cloudflare Workers. | ||
|
|
||
| ## Workflows | ||
|
|
||
| ### 1. 🚀 Deploy to Production (`deploy.yml`) | ||
| **Triggers**: Every push to `main` branch | ||
| **Actions**: | ||
| - Builds and tests the React app | ||
| - Deploys Cloudflare Worker for push notifications | ||
| - Builds notification bot Docker image | ||
| - Optionally deploys to GitHub Pages | ||
| - Sends deployment notifications | ||
|
|
||
| ### 2. 🛠️ Setup Cloudflare Infrastructure (`setup.yml`) | ||
| **Triggers**: Manual only (run once) | ||
| **Actions**: | ||
| - Creates Cloudflare KV namespace | ||
| - Updates `wrangler.toml` with namespace ID | ||
| - Commits changes back to repository | ||
|
|
||
| ### 3. ✅ Validate Environment (`validate.yml`) | ||
| **Triggers**: Pull requests to `main`, manual | ||
| **Actions**: | ||
| - Checks all required secrets are configured | ||
| - Validates configuration files | ||
| - Ensures KV namespace is set up | ||
|
|
||
| ## Initial Setup | ||
|
|
||
| ### Step 1: Configure GitHub Secrets | ||
|
|
||
| Go to **Settings → Secrets and variables → Actions** and add: | ||
|
|
||
| | Secret Name | Description | How to Get | | ||
| |------------|-------------|------------| | ||
| | `CLOUDFLARE_API_TOKEN` | Cloudflare API token with Workers permissions | [Create token](https://dash.cloudflare.com/profile/api-tokens) | | ||
| | `BOT_TOKEN` | Shared secret for bot authentication | Run: `openssl rand -base64 32` | | ||
| | `VAPID_PUBLIC_KEY` | Public key for Web Push | Run: `./generate-vapid-keys.sh` | | ||
| | `VAPID_PRIVATE_KEY` | Private key for Web Push | Run: `./generate-vapid-keys.sh` | | ||
| | `DISCORD_WEBHOOK` | (Optional) Discord webhook for notifications | Discord server settings | | ||
|
|
||
| ### Step 2: Create Cloudflare API Token | ||
|
|
||
| 1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com/profile/api-tokens) | ||
| 2. Click "Create Token" | ||
| 3. Use "Edit Cloudflare Workers" template | ||
| 4. Set permissions: | ||
| - Account: Cloudflare Workers Scripts: Edit | ||
| - Account: Account Settings: Read | ||
| - Zone: Workers Routes: Edit | ||
| 5. Click "Continue to summary" → "Create Token" | ||
| 6. Copy the token to GitHub Secrets | ||
|
|
||
| ### Step 3: Run Setup Workflow | ||
|
|
||
| 1. Go to **Actions** tab | ||
| 2. Select "Setup Cloudflare Infrastructure" | ||
| 3. Click "Run workflow" | ||
| 4. This will create the KV namespace and update `wrangler.toml` | ||
|
|
||
| ### Step 4: Update Frontend Configuration | ||
|
|
||
| Create `.env.production` in your repository: | ||
| ```env | ||
| VITE_WORKER_URL=https://chorus-notifications.YOUR-ACCOUNT.workers.dev | ||
| VITE_VAPID_PUBLIC_KEY=${{ secrets.VAPID_PUBLIC_KEY }} | ||
| ``` | ||
|
|
||
| ## Deployment Process | ||
|
|
||
| ### Automatic Deployment | ||
|
|
||
| Every push to `main` will: | ||
| 1. Run tests and type checking | ||
| 2. Build the application | ||
| 3. Deploy worker to Cloudflare | ||
| 4. Build notification bot | ||
| 5. Send success/failure notifications | ||
|
|
||
| ### Manual Deployment | ||
|
|
||
| To manually trigger deployment: | ||
| 1. Go to **Actions** → "Deploy to Production" | ||
| 2. Click "Run workflow" | ||
| 3. Select `main` branch | ||
| 4. Click "Run workflow" | ||
|
|
||
| ## Monitoring Deployments | ||
|
|
||
| ### GitHub Actions Dashboard | ||
| - View real-time logs | ||
| - Check deployment status | ||
| - Download build artifacts | ||
|
|
||
| ### Cloudflare Dashboard | ||
| - Monitor worker performance | ||
| - View KV storage usage | ||
| - Check error logs | ||
|
|
||
| ### Notification Bot | ||
| The bot Docker image is built but needs to be deployed separately to your hosting platform. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "KV namespace ID not configured" | ||
| Run the "Setup Cloudflare Infrastructure" workflow first. | ||
|
|
||
| ### "Missing required secrets" | ||
| Add all required secrets in GitHub Settings. | ||
|
|
||
| ### "Deployment failed" | ||
| 1. Check the workflow logs | ||
| 2. Verify Cloudflare API token permissions | ||
| 3. Ensure `wrangler.toml` is properly configured | ||
|
|
||
| ### Worker not updating | ||
| 1. Check Cloudflare dashboard for the latest version | ||
| 2. Clear Cloudflare cache if needed | ||
| 3. Verify the worker URL in production | ||
|
|
||
| ## Local Development | ||
|
|
||
| To test the workflows locally: | ||
| ```bash | ||
| # Install act (GitHub Actions emulator) | ||
| brew install act | ||
|
|
||
| # Test the deployment workflow | ||
| act push -s CLOUDFLARE_API_TOKEN=your-token | ||
|
|
||
| # Test with secrets from .env file | ||
| act push --secret-file .env.secrets | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Test locally first**: Run `npm run build` before pushing | ||
| 2. **Use pull requests**: All changes should go through PR workflow | ||
| 3. **Monitor deployments**: Check the Actions tab after pushing | ||
| 4. **Keep secrets secure**: Never commit secrets to the repository | ||
| 5. **Version your worker**: Use git tags for releases | ||
|
|
||
| ## Rollback Process | ||
|
|
||
| If a deployment causes issues: | ||
|
|
||
| ### Option 1: Cloudflare Dashboard | ||
| 1. Go to Workers → your-worker | ||
| 2. Click "Deployments" tab | ||
| 3. Find previous version | ||
| 4. Click "Rollback" | ||
|
|
||
| ### Option 2: Git Revert | ||
| ```bash | ||
| # Revert the problematic commit | ||
| git revert <commit-hash> | ||
| git push origin main | ||
|
|
||
| # This will trigger a new deployment with the reverted code | ||
| ``` | ||
|
|
||
| ## Cost Considerations | ||
|
|
||
| - **GitHub Actions**: 2,000 minutes/month free | ||
| - **Cloudflare Workers**: 100,000 requests/day free | ||
| - **KV Storage**: 1 GB free | ||
| - **Estimated monthly usage**: Well within free tiers | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - API tokens are stored as encrypted secrets | ||
| - Worker deployments use secure API authentication | ||
| - Bot tokens are rotated regularly | ||
| - VAPID keys should be unique per environment | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| - [ ] Add staging environment workflow | ||
| - [ ] Implement automated bot deployment | ||
| - [ ] Add performance testing | ||
| - [ ] Create rollback workflow | ||
| - [ ] Add security scanning | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove or tailor irrelevant setup instructions
Sections on VAPID keys, BOT_TOKEN, and Discord webhooks relate to the notification system, not the relay crawler. This content should be removed or separated into its own documentation to avoid confusion.
🤖 Prompt for AI Agents