Skip to content

Commit a75e1e4

Browse files
Merge pull request #1891 from jasonrandrews/review2
update monthly reports for Learning Paths
2 parents 35ec30c + cd0f76a commit a75e1e4

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

.github/workflows/monthly-report.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,11 @@ jobs:
2727
run: |
2828
python tools/generate_monthly_report.py
2929
30-
- name: Create data directory if not exists
31-
run: mkdir -p data/reports
32-
33-
- name: Move report to data directory
34-
run: |
35-
REPORT_FILE=$(ls LP-report-*.md | head -n 1)
36-
mv "$REPORT_FILE" data/reports
37-
3830
- name: Commit and push report to repository
3931
run: |
4032
git config user.name github-actions
4133
git config user.email [email protected]
42-
git add data/reports/
34+
git add reports/
4335
git commit -m "Add monthly learning path report [skip ci]" || echo "No changes to commit"
4436
git push
4537
env:

.github/workflows/test-lp.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
with:
1919
files: |
2020
**.md
21+
ignore-paths: |
22+
reports/**
2123
- name: Check for capital letters or spaces in content directory
2224
run: |
2325
echo "Checking for capital letters or spaces in content directory paths (excluding file extensions)..."

tools/generate_monthly_report.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import requests
22
import datetime
3-
import os
43
import json
54
from bs4 import BeautifulSoup
5+
import contextlib
6+
import argparse
7+
import sys
8+
import os # Add os import for directory handling
69

710
# GitHub API settings
811
GITHUB_API_URL = "https://api.github.com/graphql"
@@ -293,9 +296,9 @@ def get_html_title(url):
293296
return None
294297

295298
if __name__ == "__main__":
296-
import sys
297-
import argparse
298-
import contextlib
299+
# Ensure the reports directory exists in the current working directory
300+
reports_dir = os.path.join(os.getcwd(), "reports")
301+
os.makedirs(reports_dir, exist_ok=True)
299302

300303
parser = argparse.ArgumentParser(description="Generate Learning Path monthly report.")
301304
parser.add_argument("--month", type=str, help="Month to generate report for (format: YYYY-MM). Defaults to current month.")
@@ -332,10 +335,10 @@ def get_html_title(url):
332335
month_filter = datetime.date.today().strftime("%Y-%m")
333336

334337
if month_range:
335-
output_filename = f"LP-report-{month_range[0].strftime('%Y-%m')}_to_{month_range[1].strftime('%Y-%m')}.md"
338+
output_filename = os.path.join(reports_dir, f"LP-report-{month_range[0].strftime('%Y-%m')}_to_{month_range[1].strftime('%Y-%m')}.md")
336339
else:
337340
report_month = datetime.datetime.strptime(month_filter, "%Y-%m")
338-
output_filename = f"LP-report-{report_month.strftime('%Y-%m')}.md"
341+
output_filename = os.path.join(reports_dir, f"LP-report-{report_month.strftime('%Y-%m')}.md")
339342

340343
with open(output_filename, "w") as f:
341344
with contextlib.ExitStack() as stack:

0 commit comments

Comments
 (0)