Sponsorship auto-generate v0.1.37
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: '33 10 * * *' # Set your preferred schedule (UTC)
|
- cron: '50 10 * * *' # Set your preferred schedule (UTC)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-readme:
|
update-readme:
|
||||||
|
|||||||
@@ -95,41 +95,42 @@ def update_readme(sponsors_table):
|
|||||||
global headers
|
global headers
|
||||||
repo_owner = "jokob-sk"
|
repo_owner = "jokob-sk"
|
||||||
repo_name = "Pi.Alert"
|
repo_name = "Pi.Alert"
|
||||||
readme_path = "README.md"
|
|
||||||
|
|
||||||
with open(readme_path, "r") as readme_file:
|
# Update the README.md file in the GitHub repository
|
||||||
readme_content = readme_file.read()
|
api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/contents/README.md"
|
||||||
|
|
||||||
|
# Fetch the current content of the README.md file
|
||||||
|
response = requests.get(api_url, headers=headers)
|
||||||
|
readme_data = response.json()
|
||||||
|
|
||||||
# Find the start and end markers
|
# Find the start and end markers
|
||||||
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
|
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
|
||||||
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
|
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
|
||||||
|
|
||||||
# Replace the content between markers with the generated sponsors table
|
# Replace the content between markers with the generated sponsors table
|
||||||
start_index = readme_content.find(start_marker)
|
start_index = readme_data.find(start_marker)
|
||||||
end_index = readme_content.find(end_marker, start_index + len(start_marker))
|
end_index = readme_data.find(end_marker, start_index + len(start_marker))
|
||||||
if start_index != -1 and end_index != -1:
|
if start_index != -1 and end_index != -1:
|
||||||
updated_readme = (
|
updated_readme = (
|
||||||
readme_content[:start_index + len(start_marker)]
|
readme_data[:start_index + len(start_marker)]
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ sponsors_table
|
+ sponsors_table
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ readme_content[end_index:]
|
+ readme_data[end_index:]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("Markers not found in README.md. Make sure they are correctly placed.")
|
print("Markers not found in README.md. Make sure they are correctly placed.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Update the README.md file in the GitHub repository
|
updated_content_base64 = base64.b64encode(readme_data.encode()).decode()
|
||||||
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
|
# Create a commit to update the README.md file
|
||||||
commit_message = "[🤖Automation] Update README with sponsors information"
|
commit_message = "[🤖Automation] Update README with sponsors information"
|
||||||
commit_data = {
|
commit_data = {
|
||||||
"message": commit_message,
|
"message": commit_message,
|
||||||
"content": updated_content_base64,
|
"content": updated_content_base64,
|
||||||
|
"sha": readme_data["sha"],
|
||||||
"branch": "main", # Update the branch name as needed
|
"branch": "main", # Update the branch name as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user