diff --git a/.github/workflows/update_sponsors.yml b/.github/workflows/update_sponsors.yml
index ed965c6a..4f99f50a 100755
--- a/.github/workflows/update_sponsors.yml
+++ b/.github/workflows/update_sponsors.yml
@@ -2,7 +2,7 @@ name: Update Sponsors
on:
schedule:
- - cron: '0 4 * * *' # Set your preferred schedule (UTC)
+ - cron: '0 10 * * *' # Set your preferred schedule (UTC)
jobs:
update-readme:
diff --git a/README.md b/README.md
index b602a025..4138be15 100755
--- a/README.md
+++ b/README.md
@@ -84,7 +84,7 @@ Get visibility of what's going on on your WIFI/LAN network. Scan for devices, po
Click for more ways to donate
-
+
- Bitcoin: `1N8tupjeCK12qRVU2XrV17WvKK7LCawyZM`
- Ethereum: `0x6e2749Cb42F4411bc98501406BdcD82244e3f9C7`
@@ -98,11 +98,9 @@ Get visibility of what's going on on your WIFI/LAN network. Scan for devices, po
Thank you to all the wonderful people who have sponsored this project (=prevented my burnout):
-
+
-
-
-
+
## Everything else
diff --git a/update_sponsors.py b/update_sponsors.py
index 2f221fbc..28d9e68a 100755
--- a/update_sponsors.py
+++ b/update_sponsors.py
@@ -1,5 +1,6 @@
import os
import requests
+import base64
def fetch_sponsors():
graphql_url = "https://api.github.com/graphql"
@@ -87,15 +88,59 @@ def generate_sponsors_table(current_sponsors, past_sponsors):
return current_table + "\n" + past_table
def update_readme(sponsors_table):
+
+ repo_owner = "jokob-sk"
+ repo_name = "Pi.Alert"
readme_path = "README.md"
+
with open(readme_path, "r") as readme_file:
readme_content = readme_file.read()
- # Replace the placeholder with the generated sponsors table
- updated_readme = readme_content.replace("", sponsors_table)
+ # Find the start and end markers
+ start_marker = ""
+ end_marker = ""
+
+ # Replace the content between markers with the generated sponsors table
+ start_index = readme_content.find(start_marker)
+ end_index = readme_content.find(end_marker, start_index + len(start_marker))
+ if start_index != -1 and end_index != -1:
+ updated_readme = (
+ readme_content[:start_index + len(start_marker)]
+ + "\n"
+ + sponsors_table
+ + "\n"
+ + readme_content[end_index:]
+ )
+ else:
+ print("Markers not found in README.md. Make sure they are correctly placed.")
+ return
+
+
+ # Update the README.md file in the GitHub repository
+ api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/contents/README.md"
+
+ updated_content_base64 = base64.b64encode(readme_content.encode()).decode()
+
+ # Create a commit to update the README.md file
+ commit_message = "[đŸ¤–Automation] Update README with sponsors information"
+ commit_data = {
+ "message": commit_message,
+ "content": updated_content_base64,
+ "sha": readme_data["sha"],
+ "branch": "main", # Update the branch name as needed
+ }
+
+ commit_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/contents/README.md"
+ commit_response = requests.put(commit_url, headers=headers, json=commit_data)
+
+ if commit_response.status_code == 200:
+ print("README.md updated successfully in the GitHub repository.")
+ else:
+ print(f"Failed to update README.md. Status code: {commit_response.status_code}")
+ print(commit_response.json())
+
+ print("README.md updated successfully with the sponsors table.")
- with open(readme_path, "w") as readme_file:
- readme_file.write(updated_readme)
def main():
sponsors_data = fetch_sponsors()