Skip to content

Generate Monthly Report #7

Generate Monthly Report

Generate Monthly Report #7

name: Generate Monthly Report
on:
schedule:
# First Monday of each month at 10:00 UTC
- cron: "0 10 1-7 * 1"
workflow_dispatch: # Allow manual triggering for testing
permissions:
contents: write # For git commits
pull-requests: write # For creating PRs and enabling auto-merge
jobs:
generate-report:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for contributor tracking
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Generate monthly report
id: generate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run generate-report
continue-on-error: true
- name: Check generation result
if: steps.generate.outcome == 'failure'
run: |
echo "::warning::Report generation encountered errors but will attempt commit"
- name: Create feature branch
run: |
BRANCH_NAME="monthly-report/$(date +%Y-%m)"
git checkout -b "$BRANCH_NAME"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit changes to branch
run: |
git add reports/
[ -f static/data/contributors-history.json ] && git add static/data/contributors-history.json || true
git diff --staged --quiet || git commit -m "docs(reports): add monthly report for $(date +%B\ %Y)"
- name: Push branch and create PR
run: |
BRANCH_NAME="monthly-report/$(date +%Y-%m)"
git push -u origin "$BRANCH_NAME"
gh pr create \
--title "docs(reports): Monthly report for $(date +%B\ %Y)" \
--body "$(cat <<'EOFBODY'
## Automated Monthly Report
This PR contains the automated monthly report generated on $(date +%Y-%m-%d).
### Contents
- Monthly activity summary
- Contributor statistics
- Project updates
### Automated Checks
- [ ] Build passes
- [ ] No lint errors
- [ ] Report renders correctly
**Note:** This PR was automatically generated by the monthly-reports workflow.
EOFBODY
)" \
--base main \
--head "$BRANCH_NAME"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge
run: |
BRANCH_NAME="monthly-report/$(date +%Y-%m)"
gh pr merge --auto --merge "$BRANCH_NAME"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}