Skip to content

Commit

Permalink
README list action
Browse files Browse the repository at this point in the history
I stole the action yml from leachim6/hello-world I'm sorry
  • Loading branch information
ghluka committed Mar 29, 2024
1 parent 2f05772 commit 67dd61a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update README

on:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Update README
run: python update_list.py

- id: last-commit-message
run: echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
- id: get-author-name
run: echo "msg=$(git log -1 --pretty=%an)" >> $GITHUB_OUTPUT
- id: get-author-email
run: echo "msg=$(git log -1 --pretty=%aE)" >> $GITHUB_OUTPUT

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: ${{ steps.get-author-name.outputs.msg }}
commit_user_email: ${{ steps.get-author-email.outputs.msg }}
commit_author: ${{ steps.get-author-name.outputs.msg }} <${{ steps.get-author-email.outputs.msg }}>
commit_message: ${{ steps.last-commit-message.outputs.msg }}
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feel free to contribute by opening a pull request and adding a new language to o

## ⌨️ Naming

- Use spaces instead of hyphens or underscores (e.g. `Objective C.m` instead of `Objective-C.m`)
- Use spaces instead of hyphens or underscores (e.g. `Objective C` instead of `Objective-C`)

### 📂 Directories

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ Excerpt from [Wikipedia](https://en.wikipedia.org/wiki/Fibonacci_sequence):

## 📥 Contributing

We welcome contributions, to see our rules and guidelines on contributing please read [CONTRIBUTING.md](CONTRIBUTING.md)
We welcome contributions, to see our rules and guidelines on contributing please read [CONTRIBUTING.md](CONTRIBUTING.md)

# 🌐 Languages <!-- Languages start -->

<!-- Languages end -->
27 changes: 27 additions & 0 deletions update_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
"""Updates the list of languages in the README using GitHub Actions
"""

import glob
import urllib.parse

subsitutes = { '∕':'/', '\':'\\', '˸':':', '∗':'*', '?':'?', '"':'"', '﹤':'<', '﹥':'>', '❘':'|' }

files = glob.glob("./src/*/*", recursive=True)
with open('README.md', 'r', encoding='utf-8') as f:
f_text = f.read()
md = f_text.split("<!-- Languages start -->")[0]
md += f"<!-- Languages start -->[{len(files)} total]\n"

for file in files:
file = file.replace("\\", "/")
language = file.split("/")[-1]
for k in subsitutes.keys():
language = language.replace(k, subsitutes[k])
md += f"\n- [{language}]({urllib.parse.quote(file)})"

md += '\n\n<!-- Languages end -->'
md += f_text.split("<!-- Languages end -->")[1]

with open('README.md', 'w', encoding='utf-8') as f:
f.write(md)

0 comments on commit 67dd61a

Please sign in to comment.