|
| 1 | +name: "Weekly Journalistic Summary" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + |
| 7 | +jobs: |
| 8 | + summarize: |
| 9 | + name: "Summarize Commits" |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout armbian/build |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + repository: armbian/build |
| 17 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + fetch-depth: 0 # important to get full commit history |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: '3.x' |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: pip install openai |
| 27 | + |
| 28 | + - name: Generate weekly summary |
| 29 | + env: |
| 30 | + OPENAI_API_KEY: ${{ secrets.AI_MODELS }} |
| 31 | + run: | |
| 32 | + python3 << 'EOF' |
| 33 | + import subprocess |
| 34 | + import datetime |
| 35 | + from openai import OpenAI |
| 36 | +
|
| 37 | + client = OpenAI(api_key="${OPENAI_API_KEY}") |
| 38 | +
|
| 39 | + today = datetime.date.today() |
| 40 | + last_week = today - datetime.timedelta(days=7) |
| 41 | + since = f"--since={last_week.isoformat()}" |
| 42 | +
|
| 43 | + result = subprocess.run( |
| 44 | + ["git", "log", since, "--pretty=format:%h %s"], |
| 45 | + capture_output=True, |
| 46 | + text=True |
| 47 | + ) |
| 48 | +
|
| 49 | + commits = result.stdout.strip().split("\n") |
| 50 | + filtered = [c for c in commits if "automatic" not in c.lower()] |
| 51 | +
|
| 52 | + if not filtered: |
| 53 | + print("No relevant commits found.") |
| 54 | + exit(0) |
| 55 | +
|
| 56 | + prompt = ( |
| 57 | + "Write a concise, journalist-style summary of the past week's software " |
| 58 | + "development work from these Git commits. Exclude automated tasks, and " |
| 59 | + "organize the article in a reader-friendly Markdown format:\n\n" + |
| 60 | + "\n".join(filtered) |
| 61 | + ) |
| 62 | +
|
| 63 | + response = client.chat.completions.create( |
| 64 | + model="gpt-4", |
| 65 | + messages=[{"role": "user", "content": prompt}], |
| 66 | + temperature=0.5, |
| 67 | + max_tokens=1024 |
| 68 | + ) |
| 69 | +
|
| 70 | + article = response.choices[0].message.content |
| 71 | + with open("weekly-summary.md", "w") as f: |
| 72 | + f.write(article) |
| 73 | + EOF |
| 74 | +
|
0 commit comments