generated from Fallen-Breath/fabric-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Vulpeus-Server/modrinth-readme-updater
Modrinth readme updater
- Loading branch information
Showing
3 changed files
with
487 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,38 @@ | ||
""" | ||
Update Modrinth Readme | ||
""" | ||
__author__ = 'topi_banana' | ||
|
||
import os | ||
import sys | ||
import json | ||
import requests | ||
from rich import print | ||
|
||
def throw_api(id: str, body: str = "") -> int: | ||
|
||
res = requests.patch( | ||
f"https://api.modrinth.com/v2/project/{id}", | ||
data=json.dumps({ | ||
"body": body | ||
}), | ||
headers={ | ||
"Content-Type": "application/json", | ||
"Authorization": os.environ['SECRET'], | ||
}, | ||
) | ||
|
||
if res.status_code != 204: | ||
body = res.json() | ||
print(body["error"]) | ||
print(body["description"]) | ||
sys.exit(1) | ||
|
||
def main(id: str, path: str): | ||
with open(path, encoding="utf_8") as f: | ||
body = f.read() | ||
throw_api(id, body) | ||
|
||
if __name__ == '__main__': | ||
args = sys.argv | ||
main(id=args[1], path=args[2]) |
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,22 @@ | ||
name: Update Modrinth Readme | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
update_modrinth_readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.8' | ||
architecture: 'x64' | ||
- name: Install dependencies | ||
run: pip install requests rich | ||
- name: Run Python Script | ||
run: python .github/workflows/scripts/update_modrinth_readme.py aZhtZo3k Modrinth.md | ||
env: | ||
SECRET: ${{ secrets.MODRINTH_API_TOKEN }} |
Oops, something went wrong.