-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'Used By' section and GitHub Action to update it
- Loading branch information
1 parent
b871dd1
commit 2c1d698
Showing
3 changed files
with
49 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,32 @@ | ||
name: Update Used By Section | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' # Runs every Sunday at midnight | ||
workflow_dispatch: # Allows for manual triggering of the workflow | ||
|
||
jobs: | ||
update-used-by: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Fetch repositories using this project | ||
run: | | ||
curl -H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/search/repositories?q=BlackMarlinExec+in:file \ | ||
> used_by_repos.json | ||
- name: Update README | ||
run: | | ||
python update_readme.py | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add README.md | ||
git commit -m 'Update Used By section' | ||
git push |
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,17 @@ | ||
import json | ||
|
||
with open('used_by_repos.json') as f: | ||
data = json.load(f) | ||
|
||
repos = data.get('items', []) | ||
|
||
with open('README.md', 'r') as f: | ||
lines = f.readlines() | ||
|
||
start_idx = next(i for i, line in enumerate(lines) if line.strip() == "## Used By") + 1 | ||
end_idx = next((i for i, line in enumerate(lines[start_idx:], start=start_idx) if line.startswith("##")), len(lines)) | ||
|
||
new_lines = lines[:start_idx] + [f"- [{repo['full_name']}]({repo['html_url']}): {repo.get('description', 'No description available')}\n" for repo in repos] + lines[end_idx:] | ||
|
||
with open('README.md', 'w') as f: | ||
f.writelines(new_lines) |