Skip to content

fix(data-sync): fix scraper not running in Bun ESM + add manual trigger#813

Merged
ImJustChew merged 1 commit into
mainfrom
claude/data-scraper-docker-gcp-3hjWv
Jun 5, 2026
Merged

fix(data-sync): fix scraper not running in Bun ESM + add manual trigger#813
ImJustChew merged 1 commit into
mainfrom
claude/data-scraper-docker-gcp-3hjWv

Conversation

@ImJustChew

Copy link
Copy Markdown
Member
  • Replace require.main === module with import.meta.main in both
    sync-courses.ts and update-courses.ts — the old check doesn't work in
    Bun ESM (module: esnext), causing the Docker container to exit silently
    without ever running the scraper
  • Fix run-docker.sh to use bun run instead of tsx (tsx is not
    installed in the container)
  • Add workflow_dispatch trigger to build.yaml with a run-scraper job so
    the scraper can be manually triggered from the GitHub Actions UI
    with a configurable semester parameter

https://claude.ai/code/session_01RbmtUdLaaURBWLK2BrXfok

- Replace `require.main === module` with `import.meta.main` in both
  sync-courses.ts and update-courses.ts — the old check doesn't work in
  Bun ESM (module: esnext), causing the Docker container to exit silently
  without ever running the scraper
- Fix run-docker.sh to use `bun run` instead of `tsx` (tsx is not
  installed in the container)
- Add workflow_dispatch trigger to build.yaml with a run-scraper job so
  the scraper can be manually triggered from the GitHub Actions UI
  with a configurable semester parameter

https://claude.ai/code/session_01RbmtUdLaaURBWLK2BrXfok
Copilot AI review requested due to automatic review settings June 5, 2026 01:49
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
courseweb-web 3b4c2cc Commit Preview URL

Branch Preview URL
Jun 05 2026, 01:46 AM

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
courseweb Ready Ready Preview Jun 5, 2026 1:49am

@ImJustChew ImJustChew merged commit af49ab4 into main Jun 5, 2026
7 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the data-sync scraper entrypoints and tooling to run correctly under Bun ESM (preventing silent exits), and adds a manual GitHub Actions trigger to run the scraper on demand.

Changes:

  • Switch “run directly” guards in sync-courses.ts / update-courses.ts to Bun-friendly semantics.
  • Update run-docker.sh to invoke the scraper with bun run instead of tsx.
  • Add workflow_dispatch + a run-scraper job to allow manual scraper runs with a semester input.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
tools/data-sync/src/update-courses.ts Updates the scheduled sync CLI entrypoint guard for Bun ESM execution.
tools/data-sync/src/sync-courses.ts Updates the one-shot sync CLI entrypoint guard for Bun ESM execution.
tools/data-sync/run-docker.sh Uses Bun to run the sync scripts inside the Docker container.
.github/workflows/build.yaml Adds a manually-triggerable Actions job to run the scraper with secrets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// If this file is run directly, execute the sync
if (require.main === module) {
if (import.meta.main) {

// If this file is run directly, start the scheduled sync
if (require.main === module) {
if (import.meta.main) {
Comment on lines 159 to 164
# Set command based on mode
if [[ "$MODE" == "once" ]]; then
CMD="tsx src/sync-courses.ts $SEMESTER"
CMD="bun run src/sync-courses.ts $SEMESTER"
else
CMD="tsx src/update-courses.ts \"$CRON_PATTERN\" $SEMESTER"
CMD="bun run src/update-courses.ts \"$CRON_PATTERN\" $SEMESTER"
fi
Comment on lines +166 to +172
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
SEMESTER: ${{ github.event.inputs.semester || '11510' }}
run: bun run src/sync-courses.ts ${{ github.event.inputs.semester || '11510' }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants