Skip to content

fix(sportySync): drive sporty.no sync via GitHub Actions cron (SWA managed functions ignore timer triggers) - #269

Merged
ChristopherRotnes merged 1 commit into
masterfrom
claude/sporty-sync-import-issue-88k37r
Jun 25, 2026
Merged

fix(sportySync): drive sporty.no sync via GitHub Actions cron (SWA managed functions ignore timer triggers)#269
ChristopherRotnes merged 1 commit into
masterfrom
claude/sporty-sync-import-issue-88k37r

Conversation

@ChristopherRotnes

Copy link
Copy Markdown
Owner

Summary

The automatic sporty.no calendar sync never ran in production. It was implemented as an Azure Functions timer trigger (app.timer('sportySyncTimer', ...)), but the app deploys as Azure Static Web Apps managed functions (api_location: "app/api"), which run HTTP triggers only — timer/cron triggers are silently ignored and never register (Microsoft Learn, SWA FAQ). The secondary AZURE_FUNCTIONS_ENVIRONMENT === 'Production' guard was moot. Nothing else called the sync endpoint on a schedule, so gym_calendar was never refreshed.

Fix

Drive the sync externally, keeping all code in this repo (chosen approach: GitHub Actions cron + machine auth):

  • Removed the dead timer trigger in sportySync.js; replaced with a comment documenting the platform limitation.
  • New .github/workflows/sporty-sync.yml — scheduled cron at 04:00, 11:00, 14:00, 22:00 UTC (+ workflow_dispatch) that POSTs to /api/sporty-sync with {"daysBack": 7} (self-healing lookback), with curl retries.
  • POST /api/sporty-sync now accepts machine authX-Api-Key: <SPORTY_SYNC_API_KEY> for automation, in addition to the existing X-Supabase-Token JWT for manual kicks from a signed-in user. The fetch/parse/upsert logic was already correct and is unchanged.

Setup required before this works

Add two GitHub Actions repository secrets:

Secret Value
SPORTY_SYNC_URL https://workout.umulig.org/api/sporty-sync
SPORTY_SYNC_API_KEY same value as the SPORTY_SYNC_API_KEY app setting already configured in Azure

Then trigger once manually via Actions → Sporty sync → Run workflow to backfill, and verify with GET /api/sporty-health.

Docs

Verification

  • npm test → 92 passed · npm run lint → clean
  • Live sporty.no call could not be exercised here (egress policy blocks sporty.no); logic paths are unchanged from the previously working sync.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FwvkU2RBksppoWttDEcfB1


Generated by Claude Code

…ctions ignore timer triggers

Azure Static Web Apps managed functions run HTTP triggers only; the
app.timer('sportySyncTimer', ...) trigger never registered in production,
so the sporty.no calendar sync never ran.

- Remove the dead timer trigger; document the platform limitation (#270)
- Add .github/workflows/sporty-sync.yml cron (04/11/14/22 UTC, daysBack=7)
- Accept X-Api-Key (SPORTY_SYNC_API_KEY) machine auth on POST /api/sporty-sync
  alongside the existing X-Supabase-Token JWT for manual kicks
- Update CLAUDE.md, README.md, CHANGELOG.md; bump version to 1.5.17

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FwvkU2RBksppoWttDEcfB1
@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-269.westeurope.7.azurestaticapps.net

@ChristopherRotnes
ChristopherRotnes marked this pull request as ready for review June 25, 2026 05:23
@ChristopherRotnes
ChristopherRotnes merged commit 82840fa into master Jun 25, 2026
2 checks passed
@ChristopherRotnes
ChristopherRotnes deleted the claude/sporty-sync-import-issue-88k37r branch June 25, 2026 05:32
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.

2 participants