Skip to content

feat: persist data/ to repository in GitHub Action workflow#43

Merged
unhappychoice merged 6 commits intomainfrom
feat/action-data-persistence
Apr 3, 2026
Merged

feat: persist data/ to repository in GitHub Action workflow#43
unhappychoice merged 6 commits intomainfrom
feat/action-data-persistence

Conversation

@unhappychoice
Copy link
Copy Markdown
Member

Summary

  • Add git commit & push steps to action.yml so data/ persists between workflow runs
  • Daily events accumulate correctly across multiple cron runs
  • Weekly pipeline can read previously accumulated events

How it works

Daily cron (every midnight):
  checkout repo → daily-fetch → commit data/ → push

Weekly cron (Monday 9am):
  checkout repo → weekly-fetch → generate → commit data/ → push → render → deploy gh-pages

Changes

  • Configure git: set bot user name/email at the start
  • Commit data (daily): git add data/ && git commit && git push after daily-fetch
  • Commit data (weekly): same after weekly-fetch + generate
  • Idempotent: skips commit when there are no changes

Caller workflow requirement

The workflow using this action must include actions/checkout before invoking:

steps:
  - uses: actions/checkout@v4
  - uses: deariary/github-weekly-reporter@v1
    with:
      github-token: ${{ secrets.GITHUB_TOKEN }}
      mode: daily

Closes #33

Add git commit & push steps after daily-fetch and weekly-fetch/generate
so that accumulated events and report data survive between workflow runs.

- Configure git user as github-weekly-reporter[bot]
- Daily mode: commit data/ after event accumulation
- Weekly mode: commit data/ after fetch + generate, then render and deploy
- Skip commit when no changes (idempotent)

The caller workflow must use actions/checkout before this action so the
repository is available for git operations.

Closes #33
Add 'date' input (YYYY-MM-DD) to the action. When provided, all
commands target the week containing that date instead of the current
week. This enables generating past week reports via workflow_dispatch.
The --date flag was parsed as UTC noon (T12:00:00Z), which could resolve
to a different day in timezones far from UTC (e.g. Pacific/Kiritimati
UTC+14). Now parseLocalDate() uses midnightInTz to find the correct UTC
instant for noon of the given date in the user's configured timezone.
action.yml:
- Set authenticated remote URL with token for reliable git push
- Add git pull --rebase before push to handle concurrent runs
- Add --date flag to deploy step
- Document contents: write permission requirement

Timezone fixes:
- Add parseLocalDate() with input validation (YYYY-MM-DD regex)
- Use parseLocalDate in all CLI commands instead of UTC noon hack
- Fix formatDate in i18n to use parseLocalDate
- Fix weekday helper to use timezone-aware day resolution
- Add --date flag to deploy command

Other:
- Add data/, output/, tmp/ to .gitignore
- Add 9 tests for parseLocalDate (various timezones, edge cases)
Write token to ~/.git-credentials and use git credential.helper store.
This avoids token leakage in command-line arguments or step logs.
actions/checkout@v4 already configures git credentials via
persist-credentials (default: true). No need to duplicate it.
@unhappychoice unhappychoice merged commit c6824ff into main Apr 3, 2026
2 checks passed
@unhappychoice unhappychoice deleted the feat/action-data-persistence branch April 3, 2026 22:29
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.

Set up GitHub Action workflow for daily-fetch and weekly report generation

1 participant