feat(cosmic-daily): schedule daily run, keep PR review manual - #39
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
DEMO_KEY is a globally shared, rate-limited key that can respond slowly under load. The previous 20s timeout caused the GitHub Actions workflow to fail with a read timeout. Use a (10s connect, 45s read) timeout and retry up to 3 times with backoff before failing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
# Conflicts: # tools/cosmic-daily/cosmic_daily/nasa_client.py
Also removed the tools/cosmic-daily/cosmic_daily.egg-info directory that was accidentally tracked from a local pip install -e . run. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds a daily cron trigger (12:00 UTC) so Cosmic Daily runs automatically without needing a manual workflow_dispatch. Scheduled runs always generate + open a PR (never auto-merge), preserving human review before publication. Manual dispatch keeps its existing publish/date inputs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Scheduled runs may fail because the workflow references the inputs.* context in schedule executions, which should be made safe before enabling the daily trigger.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a daily scheduled trigger to the “Cosmic Daily” GitHub Actions workflow so it can automatically generate the APOD post and open a pull request for human review, while preserving manual workflow_dispatch behavior. It also improves resilience of the NASA APOD fetch logic with a more generous timeout and retry behavior.
Changes:
- Add a
scheduletrigger (daily at 12:00 UTC) and route scheduled runs to “publish” mode (generate + open PR, no auto-merge). - Add request timeout tuning and retry/backoff logic to the NASA APOD client.
- Ignore Python
*.egg-info/artifacts in git.
File summaries
| File | Description |
|---|---|
| tools/cosmic-daily/cosmic_daily/nasa_client.py | Adds timeout constants and retry/backoff around APOD fetches. |
| .gitignore | Ignores Python package metadata directories (*.egg-info/). |
| .github/workflows/cosmic-daily.yml | Adds daily schedule trigger and publishes on scheduled runs while keeping manual dispatch behavior. |
Review details
Suppressed comments (1)
.github/workflows/cosmic-daily.yml:64
- This step also references the
inputscontext (${{ inputs.publish }}), which may be undefined for scheduled runs even though the bashifwould choose the other branch. Usegithub.event.inputs.publishwith a fallback to avoid potential evaluation errors onschedule.
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "publish=${{ inputs.publish }}" >> "$GITHUB_OUTPUT"
fi
- Files reviewed: 2/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| target="${{ inputs.date }}" | ||
| if [ -z "$target" ]; then | ||
| target="$(date -u +%F)" | ||
| fi | ||
| echo "value=$target" >> "$GITHUB_OUTPUT" |
| response = None | ||
| last_error: requests.RequestException | None = None | ||
| for attempt in range(1, MAX_ATTEMPTS + 1): | ||
| try: | ||
| response = requests.get( | ||
| APOD_ENDPOINT, | ||
| params={"api_key": configured_key, "date": target_day}, | ||
| timeout=REQUEST_TIMEOUT, | ||
| allow_redirects=False, | ||
| ) | ||
| break | ||
| except requests.RequestException as exc: | ||
| last_error = exc | ||
| if attempt < MAX_ATTEMPTS: | ||
| time.sleep(RETRY_BACKOFF_SECONDS * attempt) | ||
| if response is None: | ||
| raise RuntimeError( | ||
| f"Failed to fetch APOD for {target_day} after {MAX_ATTEMPTS} attempts: {last_error}" | ||
| ) from last_error | ||
|
|
||
| if response.status_code != 200: | ||
| raise RuntimeError(f"NASA API returned HTTP {response.status_code} for {target_day}") |
Ajoute un déclenchement automatique quotidien (\schedule: cron '0 12 * * *', soit 08:00 EDT / 07:00 EST) au workflow Cosmic Daily.