r/adventofcode • u/ung3froren • Dec 01 '21
Repo Fancy Badges for your GitHub Repo
So you probably all know these fancy badges displayed on Github in Repository Readmes. I'm using them to display the current day and my stars in AdventOf Code.
As I didn't want to update them by hand I createt the following github action:
https://github.com/J0B10/aoc-badges-action
It can be configured to automatically update the badges daily or whenever you push code.
I created this action last year but havn't sheared it till now.
So have fun with it!
37
Upvotes
7
u/daggerdragon Dec 01 '21
This is a neat idea. Definitely consider submitting it to this year's community fun event for Adventure Time!
I did poke through your
aoc-badges.pyin section# fetch starsand I don't see any throttling in there to prevent folks from hammering the AoC servers.As per the AoC website:
Will you add throttling? (Granted, I didn't look that hard, please point me if you actually do throttle requests somewhere else and I didn't see it.)
1
u/thedjotaku Dec 01 '21
Is there a way to set up the action to grab the user id from github secrets? Otherwise you're opening it up to everyone.
1
u/xalvador Dec 01 '21
newbie here, where is this yaml file its referring to?
3
u/skarlso Dec 01 '21
This is pretty cool! :))) Going to apply it to my repo! :)
2
u/mariotacke Dec 02 '21
Alternatively, you can load a random
jsonfile via shields.io. For example, I maintain a json file where I just increment the number of stars I received:Repo: https://github.com/mariotacke/advent-of-code-2021
1
u/ScaredDonuts Dec 02 '21
Can't seem to get it to work. It errors out at Run k2bd/advent-readme-stars@v1.0.0
Traceback (most recent call last):File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_mainreturn _run_code(code, main_globals, None,File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_codeexec(code, run_globals)File "/usr/local/lib/python3.9/site-packages/advent_readme_stars/__main__.py", line 8, in <module>edited = update_readme(lines)File "/usr/local/lib/python3.9/site-packages/advent_readme_stars/update.py", line 70, in update_readmenew_readme = insert_table(reduced)File "/usr/local/lib/python3.9/site-packages/advent_readme_stars/update.py", line 53, in insert_tablestars_info = sorted(list(get_progress()), key=lambda p: p.day)File "/usr/local/lib/python3.9/site-packages/advent_readme_stars/progress.py", line 20, in get_progressleaderboard_info = res.json()File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 910, in jsonreturn complexjson.loads(self.text, **kwargs)File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loadsreturn _default_decoder.decode(s)File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decodeobj, end = self.raw_decode(s, idx=_w(s, 0).end())File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decoderaise JSONDecodeError("Expecting value", s, err.value) from Nonejson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)