Implement Gitea Action to update README with dynamic stats
Some checks failed
Update Profile Stats / build (push) Failing after 13m55s

This commit is contained in:
2026-02-27 18:56:53 +00:00
parent 5477d6b4dd
commit b25130c615
3 changed files with 67 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
import datetime
import os
import re
def generate_stats():
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return f"✅ My Gitea instance is alive and well!\n🕒 Last update: {now}."
def main():
readme_path = "README.md"
if not os.path.exists(readme_path):
print("README.md not found!")
return
with open(readme_path, "r", encoding="utf-8") as f:
content = f.read()
# Generate new dynamic content
stats_content = generate_stats()
# Replace content between the markers
pattern = r".*?"
replacement = f"\n{stats_content}\n"
new_content = re.sub(pattern, replacement, content, flags=re.DOTALL)
# 4. Save the file back to disk
with open(readme_path, "w", encoding="utf-8") as f:
f.write(new_content)
print("README.md updated locally.")
if __name__ == "__main__":
main()