diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index bb0735f..40d19a8 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -2,7 +2,7 @@ name: Generate Stats Images
on:
push:
- branches: [ master ]
+ branches: [ master, main ]
schedule:
- cron: "5 0 * * *"
workflow_dispatch:
@@ -39,18 +39,24 @@ jobs:
python3 generate_images.py
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
+ GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ EXCLUDE_FORKED_REPOS: false
+ # Optional secrets - Python code handles None/empty values gracefully
EXCLUDED: ${{ secrets.EXCLUDED }}
EXCLUDED_LANGS: ${{ secrets.EXCLUDED_LANGS }}
- EXCLUDE_FORKED_REPOS: false
GIT_EMAILS: ${{ secrets.GIT_EMAILS }}
# Commit all changed files to the repository
- name: Commit to the repo
run: |
- git config --global user.name "AxelPCG/gitgub-stats-modified"
+ git config --global user.name "AxelPCG/github-stats-modified"
git config --global user.email "axelchepanski@hotmail.com"
- git add .
- # Force the build to succeed, even if no files were changed
- git commit -m 'Update generated files' || true
- git push
+ git add generated/
+ # Only commit if there are changes
+ if git diff --staged --quiet; then
+ echo "No changes to commit"
+ else
+ git commit -m 'Update generated files [skip ci]' || exit 1
+ git push || exit 1
+ fi
diff --git a/generate_images.py b/generate_images.py
index c20867f..b3207ef 100644
--- a/generate_images.py
+++ b/generate_images.py
@@ -32,23 +32,40 @@ async def generate_overview(s: Stats) -> None:
Generate an SVG badge with summary statistics
:param s: Represents user's GitHub statistics
"""
- with open("templates/overview.svg", "r") as f:
- output = f.read()
-
- output = re.sub("{{ name }}", await s.name, output)
- output = re.sub("{{ stars }}", f"{await s.stargazers:,}", output)
- output = re.sub("{{ forks }}", f"{await s.forks:,}", output)
- output = re.sub("{{ contributions }}", f"{await s.total_contributions:,}", output)
- output = re.sub("{{ views }}", f"{await s.views:,}", output)
- output = re.sub("{{ repos }}", f"{len(await s.repos):,}", output)
- commits = await s.total_commits
- output = re.sub("{{ commits }}", f"{commits:,}", output)
- output = re.sub("{{ prs }}", f"{await s.prs:,}", output)
- output = re.sub("{{ issues }}", f"{await s.issues:,}", output)
-
- generate_output_folder()
- with open("generated/overview.svg", "w") as f:
- f.write(output)
+ try:
+ print("Starting generation of overview.svg...")
+ with open("templates/overview.svg", "r") as f:
+ output = f.read()
+
+ print("Fetching statistics data...")
+ output = re.sub("{{ name }}", await s.name, output)
+ output = re.sub("{{ stars }}", f"{await s.stargazers:,}", output)
+ output = re.sub("{{ forks }}", f"{await s.forks:,}", output)
+ output = re.sub("{{ contributions }}", f"{await s.total_contributions:,}", output)
+ output = re.sub("{{ views }}", f"{await s.views:,}", output)
+ output = re.sub("{{ repos }}", f"{len(await s.repos):,}", output)
+ commits = await s.total_commits
+ output = re.sub("{{ commits }}", f"{commits:,}", output)
+ output = re.sub("{{ prs }}", f"{await s.prs:,}", output)
+ output = re.sub("{{ issues }}", f"{await s.issues:,}", output)
+
+ generate_output_folder()
+ output_path = "generated/overview.svg"
+ with open(output_path, "w", encoding="utf-8") as f:
+ f.write(output)
+
+ # Verify file was created and has content
+ if not os.path.exists(output_path):
+ raise FileNotFoundError(f"Failed to create {output_path}")
+ file_size = os.path.getsize(output_path)
+ if file_size == 0:
+ raise ValueError(f"Generated {output_path} is empty!")
+ print(f"Successfully generated overview.svg ({file_size} bytes)")
+ except Exception as e:
+ print(f"ERROR generating overview.svg: {e}")
+ import traceback
+ traceback.print_exc()
+ raise
async def generate_languages(s: Stats) -> None:
@@ -56,24 +73,35 @@ async def generate_languages(s: Stats) -> None:
Generate an SVG badge with summary languages used
:param s: Represents user's GitHub statistics
"""
- with open("templates/languages.svg", "r") as f:
- output = f.read()
-
- progress = ""
- lang_list = ""
- sorted_languages = sorted(
- (await s.languages).items(), reverse=True, key=lambda t: t[1].get("size")
- )
- delay_between = 150
- for i, (lang, data) in enumerate(sorted_languages):
- color = data.get("color")
- color = color if color is not None else "#000000"
- progress += (
- f''
- )
- lang_list += f"""
+ try:
+ print("Starting generation of languages.svg...")
+ with open("templates/languages.svg", "r") as f:
+ output = f.read()
+
+ print("Fetching languages data...")
+ languages = await s.languages
+ print(f"Found {len(languages)} languages")
+
+ if not languages:
+ print("WARNING: No languages found! Generating empty languages.svg")
+ progress = ""
+ lang_list = ""
+ else:
+ progress = ""
+ lang_list = ""
+ sorted_languages = sorted(
+ languages.items(), reverse=True, key=lambda t: t[1].get("size")
+ )
+ delay_between = 150
+ for i, (lang, data) in enumerate(sorted_languages):
+ color = data.get("color")
+ color = color if color is not None else "#000000"
+ progress += (
+ f''
+ )
+ lang_list += f"""