Skip to content

Commit 0b6c7df

Browse files
committed
feat: add PR links and human-readable dates to cookbook table
- Add Latest Change column with link to most recent merged PR - Format Last Updated as human-readable date (e.g. Jan 15, 2024) - Fetch latest merged PR per cookbook from GitHub API
1 parent bcf3b1a commit 0b6c7df

2 files changed

Lines changed: 45 additions & 18 deletions

File tree

.github/workflows/update-profile-readme.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ jobs:
3333
)
3434
]
3535
| .[0:10]
36-
| .[]
37-
| "| [\(.name)](\(.html_url)) | \(.description // "A Chef cookbook") | \(.updated_at | split("T")[0]) |"
38-
' > /tmp/cookbooks.txt
39-
echo "Fetched $(wc -l < /tmp/cookbooks.txt) cookbooks"
36+
' > /tmp/repos.json
37+
echo "Fetched $(jq 'length' /tmp/repos.json) cookbooks"
38+
39+
- name: Fetch latest merged PRs
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
mkdir -p /tmp/prs
44+
for repo in $(jq -r '.[].name' /tmp/repos.json); do
45+
gh api "repos/sous-chefs/${repo}/pulls?state=closed&sort=updated&direction=desc&per_page=5" \
46+
--jq '[.[] | select(.merged_at != null)][0]' \
47+
> "/tmp/prs/${repo}.json" 2>/dev/null || echo 'null' > "/tmp/prs/${repo}.json"
48+
done
4049
4150
- name: Fetch org members
4251
env:
@@ -52,12 +61,39 @@ jobs:
5261
- name: Update README
5362
run: |
5463
ruby - <<'RUBYEOF'
64+
require "json"
65+
require "time"
66+
5567
readme = "profile/README.md"
5668
content = File.read(readme)
5769
58-
rows = File.read("/tmp/cookbooks.txt").strip
70+
repos = JSON.parse(File.read("/tmp/repos.json"))
71+
72+
rows = repos.map do |repo|
73+
name = repo["name"]
74+
url = repo["html_url"]
75+
desc = repo["description"] || "A Chef cookbook"
76+
updated = Time.parse(repo["updated_at"]).strftime("%b %d, %Y")
77+
78+
pr_path = "/tmp/prs/#{name}.json"
79+
pr = begin
80+
data = JSON.parse(File.read(pr_path))
81+
data unless data.nil? || data.is_a?(String)
82+
rescue JSON::ParserError, Errno::ENOENT
83+
nil
84+
end
85+
86+
change = if pr
87+
"[#{pr['title']}](#{pr['html_url']})"
88+
else
89+
"—"
90+
end
91+
92+
"| [#{name}](#{url}) | #{desc} | #{change} | #{updated} |"
93+
end
94+
5995
unless rows.empty?
60-
table = "| Cookbook | Description | Last Updated |\n| --- | --- | --- |\n#{rows}"
96+
table = "| Cookbook | Description | Latest Change | Last Updated |\n| --- | --- | --- | --- |\n#{rows.join("\n")}"
6197
content.gsub!(/<!-- COOKBOOKS_START -->.*?<!-- COOKBOOKS_END -->/m,
6298
"<!-- COOKBOOKS_START -->\n#{table}\n<!-- COOKBOOKS_END -->")
6399
end

profile/README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,9 @@ from Chef or simply no longer wants the burden of maintaining it alone. No cookb
2727
## 🍽️ Recently Updated Cookbooks
2828

2929
<!-- COOKBOOKS_START -->
30-
| Cookbook | Description | Last Updated |
31-
| --- | --- | --- |
32-
| [certificate](https://github.com/sous-chefs/certificate) | Development repository for the certificate cookbook | 2026-04-13 |
33-
| [xinetd](https://github.com/sous-chefs/xinetd) | Development repository for the xinetd cookbook | 2026-04-12 |
34-
| [nginx](https://github.com/sous-chefs/nginx) | Development repository for the nginx cookbook | 2026-04-12 |
35-
| [postgresql](https://github.com/sous-chefs/postgresql) | Development repository for the postgresql cookbook | 2026-04-11 |
36-
| [chrony](https://github.com/sous-chefs/chrony) | Development repository for the chrony cookbook | 2026-04-10 |
37-
| [elasticsearch](https://github.com/sous-chefs/elasticsearch) | Development repository for the elasticsearch cookbook | 2026-04-10 |
38-
| [selinux](https://github.com/sous-chefs/selinux) | Development repository for the selinux cookbook | 2026-04-10 |
39-
| [aws](https://github.com/sous-chefs/aws) | Development repository for the aws cookbook | 2026-04-09 |
40-
| [percona](https://github.com/sous-chefs/percona) | Development repository for the percona cookbook | 2026-04-08 |
41-
| [hashicorp-vault](https://github.com/sous-chefs/hashicorp-vault) | Development repository for the hashicorp-vault cookbook | 2026-04-07 |
30+
| Cookbook | Description | Latest Change | Last Updated |
31+
|---------------------------------------------|----------------------------------------|---------------|--------------|
32+
| [sous-chefs](https://github.com/sous-chefs) | Check back soon — this updates weekly! |||
4233
<!-- COOKBOOKS_END -->
4334

4435
---

0 commit comments

Comments
 (0)