-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc3f439
Showing
7 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Check if README.md contains "## RFDs" | ||
if grep -q '## RFDs' README.md; then | ||
# Extract everything before the "Requests for Discussion" section | ||
head -n $(grep -n '## RFDs' README.md | cut -d: -f1) README.md > temp_README.md | ||
else | ||
# Copy the full README.md if no Requests for Discussion section exists | ||
cat README.md > temp_README.md | ||
echo "## RFDs" >> temp_README.md | ||
fi | ||
|
||
# Generate the table header | ||
echo "| RFD | State | Updated | Labels |" >> temp_README.md | ||
echo "|:----|:------|:--------|:-------|" >> temp_README.md | ||
|
||
# Initialize an array to store the ordered table rows | ||
rows=() | ||
|
||
# Loop through files matching the NNNN.md pattern | ||
for file in [0-9][0-9][0-9][0-9].md; do | ||
# Extract the RFD number from the filename | ||
rfd_number=$((10#$(basename "$file" .md))) | ||
|
||
# Extract the state from the front matter | ||
state=$(grep '^state:' "$file" | cut -d ' ' -f2-) | ||
|
||
# Extract the title from the first heading of the file | ||
title=$(grep -m 1 '^#' "$file" | sed 's/# RFD [0-9]\{1,4\} *//') | ||
|
||
# Get the last updated timestamp of the file and transform it to the YYYY-MM-DD, HH:MM format | ||
updated=$(git log -1 --format="%cI" -- "$file" | sed -E 's/T([0-9]{2}:[0-9]{2}):[0-9]{2}.*/, \1/') | ||
|
||
# Extract the labels from the front matter | ||
labels=$(grep '^labels:' "$file" | sed -E 's/labels: *//; s/ *, */, /g; s/([^, ]+)/`\1`/g') | ||
|
||
# Add the row to the table | ||
rows+=("| [RFD $rfd_number $title]($file) | $state | $updated | $labels |") | ||
done | ||
|
||
# Sort the rows array by the Updated column in descending order (newest first) | ||
sorted_rows=$(printf "%s\n" "${rows[@]}" | sort -t '|' -k 4,4r) | ||
|
||
# Add the sorted rows to the table | ||
printf "%s\n" "$sorted_rows" >> temp_README.md | ||
|
||
# Replace the original README.md with the updated one | ||
mv temp_README.md README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Update RFD Table of Contents | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
generate-summary: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Check out the repository | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Step 2: Run the Bash script to update the README.md with the RFD Table of Contents | ||
- name: Update RFD Table of Contents | ||
run: ./.github/scripts/update_toc.sh | ||
|
||
# Step 3: Commit and push the updated README.md if changes are made | ||
- name: Commit and push changes | ||
run: | | ||
git config --local user.name "github-actions" | ||
git config --local user.email "[email protected]" | ||
git add README.md | ||
git commit -m "Update RFD Table of Contents" | ||
git push | ||
if: success() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Requests for Discussion | ||
|
||
## RFDs |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Fetch all remote branches following the pattern 'rfd/XXXX' and get the latest number | ||
git fetch origin | ||
latest_branch=$(git branch -r | grep -E 'origin/rfd/[0-9]{4}' | sed 's|origin/rfd/||' | sort -n | tail -1) | ||
|
||
# Increment RFD number by one | ||
if [ -z "$latest_branch" ]; then | ||
next_number=0001 # If no branch exists, start from 0001 | ||
else | ||
next_number=$(printf "%04d" $(( $(echo "$latest_branch" | sed 's/^0*//') + 1 ))) | ||
fi | ||
|
||
# Prompt for the placeholder title of the RFD | ||
echo "Enter the title for this RFD:" | ||
read rfd_title | ||
|
||
# Reserve the branch name for the new RFD | ||
new_branch="rfd/$next_number" | ||
git checkout -b "$new_branch" | ||
|
||
# Generate a new RFD file from the template | ||
new_file="${next_number}.md" | ||
cp XXXX.md "$new_file" | ||
|
||
# Update the new file by replacing <number> and <title> placeholders | ||
sed -i "" "s/<number>/$((10#$next_number))/g" "$new_file" | ||
sed -i "" "s/<title>/${rfd_title}/g" "$new_file" | ||
|
||
# Get the current git user's name and email | ||
author_name=$(git config user.name) | ||
author_email=$(git config user.email) | ||
author="${author_name} <${author_email}>" | ||
|
||
# Append the author information to the existing 'authors' field in the front matter | ||
sed -i "" "/^authors:/ s/$/ $author/" "$new_file" | ||
|
||
# Git add the new file | ||
git add "$new_file" | ||
|
||
# Commit following the convention: 0000: Add placeholder for RFD <Title> | ||
commit_message="$next_number: Adding placeholder for RFD $rfd_title" | ||
git commit -m "$commit_message" | ||
|
||
# Push the new branch to remote | ||
git push origin "$new_branch" | ||
|
||
echo "Branch $new_branch created and pushed with file $new_file." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
authors: | ||
state: draft | ||
labels: | ||
--- | ||
|
||
# RFD <number> <title> |