Sponsorship auto-generate v0.1.34
This commit is contained in:
2
.github/workflows/update_sponsors.yml
vendored
2
.github/workflows/update_sponsors.yml
vendored
@@ -2,7 +2,7 @@ name: Update Sponsors
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 4 * * *' # Set your preferred schedule (UTC)
|
- cron: '0 10 * * *' # Set your preferred schedule (UTC)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-readme:
|
update-readme:
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ Get visibility of what's going on on your WIFI/LAN network. Scan for devices, po
|
|||||||
<summary>Click for more ways to donate</summary>
|
<summary>Click for more ways to donate</summary>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
- Bitcoin: `1N8tupjeCK12qRVU2XrV17WvKK7LCawyZM`
|
- Bitcoin: `1N8tupjeCK12qRVU2XrV17WvKK7LCawyZM`
|
||||||
- Ethereum: `0x6e2749Cb42F4411bc98501406BdcD82244e3f9C7`
|
- 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):
|
Thank you to all the wonderful people who have sponsored this project (=prevented my burnout):
|
||||||
|
|
||||||
<!-- DO NOT MODIFY BELOW -->
|
<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->
|
||||||
|
|
||||||
<!--SPONSORS-LIST-->
|
<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->
|
||||||
|
|
||||||
<!-- DO NOT MODIFY ABOVE -->
|
|
||||||
|
|
||||||
## Everything else
|
## Everything else
|
||||||
<!--- --------------------------------------------------------------------- --->
|
<!--- --------------------------------------------------------------------- --->
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
import base64
|
||||||
|
|
||||||
def fetch_sponsors():
|
def fetch_sponsors():
|
||||||
graphql_url = "https://api.github.com/graphql"
|
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
|
return current_table + "\n" + past_table
|
||||||
|
|
||||||
def update_readme(sponsors_table):
|
def update_readme(sponsors_table):
|
||||||
|
|
||||||
|
repo_owner = "jokob-sk"
|
||||||
|
repo_name = "Pi.Alert"
|
||||||
readme_path = "README.md"
|
readme_path = "README.md"
|
||||||
|
|
||||||
with open(readme_path, "r") as readme_file:
|
with open(readme_path, "r") as readme_file:
|
||||||
readme_content = readme_file.read()
|
readme_content = readme_file.read()
|
||||||
|
|
||||||
# Replace the placeholder <!--SPONSORS-LIST--> with the generated sponsors table
|
# Find the start and end markers
|
||||||
updated_readme = readme_content.replace("<!--SPONSORS-LIST-->", sponsors_table)
|
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
|
||||||
|
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
|
||||||
|
|
||||||
|
# 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():
|
def main():
|
||||||
sponsors_data = fetch_sponsors()
|
sponsors_data = fetch_sponsors()
|
||||||
|
|||||||
Reference in New Issue
Block a user