Skip to content

Commit 4bc9288

Browse files
authored
Merge pull request #3 from Howard-nolan/feature/tweak_github_workflow
Tweak GitHub Merge Workflow
2 parents ed563e9 + 9c589ed commit 4bc9288

2 files changed

Lines changed: 51 additions & 25 deletions

File tree

.github/pull_request_template.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
## Summary
2-
<!-- What this PR does in one paragraph -->
1+
## Change Summary:
2+
<!-- What changed and why (1–3 bullets or a short paragraph) -->
33

4-
## What I Learned
5-
- Why: <concept you clarified>
6-
- How: <the trick/approach that worked>
7-
- Gotcha: <pitfall you hit and fix>
8-
- Next time: <how you'll do it better>
4+
## How It Works:
5+
<!-- Briefly describe the approach/flow. Mention endpoints, data flow, key structs, retries, etc. -->
96

10-
## Demo / Evidence
11-
- curl/ screenshots / logs
12-
13-
## Follow-ups
14-
- [ ] Small TODOs for later
7+
## Additional Notes (optional):
8+
<!-- Edge cases, tradeoffs, follow-ups, links to logs/metrics, screenshots -->

.github/workflows/append-learnings.yml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,64 @@ name: Append Learnings
22
on:
33
pull_request:
44
types: [closed]
5+
56
jobs:
67
append:
78
if: github.event.pull_request.merged == true
89
runs-on: ubuntu-latest
910
permissions:
1011
contents: write
1112
pull-requests: read
13+
1214
steps:
1315
- uses: actions/checkout@v4
14-
- name: Extract learning from PR body
15-
id: extract
16+
17+
- name: Build learnings entry from PR body
18+
id: build
1619
uses: actions/github-script@v7
1720
with:
1821
script: |
19-
const body = context.payload.pull_request.body || "";
20-
// Grab the section under "## What I Learned"
21-
const match = body.match(/## What I Learned([\s\S]*?)(## |\Z)/);
22-
const learned = match ? match[1].trim() : "";
23-
core.setOutput("learned", learned);
24-
- name: Update LEARNINGS.md
25-
if: steps.extract.outputs.learned != ''
22+
// Helpers
23+
function section(name, body) {
24+
// Match "## Name:" OR "Name:" (case-insensitive), capture until blank line or end
25+
const re = new RegExp(`(?:^|\\n)##?\\s*${name}\\s*:\\s*([\\s\\S]*?)(?:\\n\\s*\\n|$)`, 'i');
26+
const m = body.match(re);
27+
return m ? m[1].trim() : '';
28+
}
29+
function mdClean(s) {
30+
// Normalize Windows newlines, trim trailing spaces
31+
return s.replace(/\r/g, '').trim();
32+
}
33+
34+
const pr = context.payload.pull_request;
35+
const body = pr.body || '';
36+
37+
const changeSummary = mdClean(section('Change Summary', body));
38+
const howItWorks = mdClean(section('How It Works', body));
39+
const notes = mdClean(section('Additional Notes', body));
40+
41+
// If everything is empty, do nothing
42+
if (!changeSummary && !howItWorks && !notes) {
43+
core.setOutput('should_update', 'false');
44+
return;
45+
}
46+
47+
const today = new Date().toISOString().slice(0,10); // YYYY-MM-DD
48+
const header = `## ${today} - PR #${pr.number}: ${pr.title}`;
49+
50+
let entry = `${header}\n\n`;
51+
if (changeSummary) entry += `**Change Summary**\n${changeSummary}\n\n`;
52+
if (howItWorks) entry += `**How It Works**\n${howItWorks}\n\n`;
53+
if (notes) entry += `**Additional Notes**\n${notes}\n\n`;
54+
55+
core.setOutput('should_update', 'true');
56+
core.setOutput('entry', entry);
57+
58+
- name: Append to LEARNINGS.md
59+
if: steps.build.outputs.should_update == 'true'
2660
run: |
27-
echo "" >> LEARNINGS.md
28-
echo "## $(date +'%Y-%m-%d') — PR #${{ github.event.pull_request.number }} ${GITHUB_REPOSITORY}" >> LEARNINGS.md
29-
echo "${{ steps.extract.outputs.learned }}" >> LEARNINGS.md
30-
echo "" >> LEARNINGS.md
61+
touch LEARNINGS.md
62+
printf "\n%s" "${{ steps.build.outputs.entry }}" >> LEARNINGS.md
3163
git config user.name "github-actions[bot]"
3264
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
3365
git add LEARNINGS.md

0 commit comments

Comments
 (0)