diff --git a/.github/workflows/update-used-by.yml b/.github/workflows/update-used-by.yml new file mode 100644 index 00000000..0d3cfa02 --- /dev/null +++ b/.github/workflows/update-used-by.yml @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/blackmarlinexec_readme.py b/blackmarlinexec_readme.py new file mode 100644 index 00000000..f7db8b0b --- /dev/null +++ b/blackmarlinexec_readme.py @@ -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)