{"id":27169492,"url":"https://github.com/arhamkhnz/github-code-analyzer","last_synced_at":"2025-09-23T10:37:55.392Z","repository":{"id":281219972,"uuid":"944464727","full_name":"arhamkhnz/github-code-analyzer","owner":"arhamkhnz","description":"Code Analyzer for GitHub fetches all your repositories, analyzes code using cloc, and updates stats automatically. It provides a breakdown of the number of lines for each language across your GitHub repositories and updates the README file.","archived":false,"fork":false,"pushed_at":"2025-03-30T01:13:51.000Z","size":20,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T02:23:10.488Z","etag":null,"topics":["github-readme","lines-of-code","profile-readme","readme-card","readme-stats"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arhamkhnz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T11:46:32.000Z","updated_at":"2025-03-30T01:13:54.000Z","dependencies_parsed_at":"2025-03-30T02:21:44.783Z","dependency_job_id":null,"html_url":"https://github.com/arhamkhnz/github-code-analyzer","commit_stats":null,"previous_names":["arhamkhnz/github-code-analyzer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhamkhnz%2Fgithub-code-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhamkhnz%2Fgithub-code-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhamkhnz%2Fgithub-code-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhamkhnz%2Fgithub-code-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arhamkhnz","download_url":"https://codeload.github.com/arhamkhnz/github-code-analyzer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994077,"owners_count":21030048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-readme","lines-of-code","profile-readme","readme-card","readme-stats"],"created_at":"2025-04-09T06:39:45.163Z","updated_at":"2025-09-23T10:37:55.386Z","avatar_url":"https://github.com/arhamkhnz.png","language":null,"readme":"# GitHub Code Analyzer\n \nA fully automated GitHub repository analyzer that counts lines of code across all your repositories and updates stats dynamically. Runs on the default branch of each repo and skips forks.\n\n\u003c!-- LANGUAGES BREAKDOWN START --\u003e\n```\n[ LANGUAGES BREAKDOWN ]\n\nJavaScript   --\u003e 137,470 lines\nTypeScript   --\u003e 114,702 lines\nJSX          --\u003e 20,576 lines\nPHP          --\u003e 5,248 lines\nOthers       --\u003e 14,994 lines\n\n[ TOTAL LINES OF CODE: 292,990 ]\n```\n\u003c!-- LANGUAGES BREAKDOWN END --\u003e\n*Stats update automatically via GitHub Actions.*\n \n## How It Works  \nThis GitHub Action automatically fetches all your public repositories (excluding forks), clones the **default branch**, and analyzes lines of code using [`cloc`](https://github.com/AlDanial/cloc). It then updates the repository’s `README.md` with the latest code statistics. The workflow runs **by default every Sunday at midnight UTC (customizable)**, keeping your stats up to date.\n\n## Usage\n\n### **Setting Up the GitHub Action**\n1. **Add the Workflow File**  \n   Copy the `analyze-code.yml` file into your repository at:\n   ```\n   .github/workflows/analyze-code.yml\n   ```\n   Then commit and push the changes.\n\n2. **Generate a GitHub Personal Access Token (PAT)**  \n   You need a **Personal Access Token (PAT)** with **`repo`** permissions.  \n   Refer to [GitHub Docs](https://github.com/settings/tokens) on how to generate one.\n\n3. **Add the Token to Repository Secrets**  \n   - Go to **Settings → Secrets and variables → Actions → New repository secret**  \n   - Name the secret **`GH_PAT`**  \n   - Paste the generated token and save.\n\n4. **Update Workflow Permissions**  \n   In the repository where you're running the action, make sure to update workflow permissions:\n   - Go to **Settings → Actions → General**.\n   - Under **Workflow permissions**, select **\"Read and write permissions\"**.\n   - This allows the workflow to update files like `README.md` automatically.\n\n5. **Trigger the Workflow**\n   - The workflow runs **by default every Sunday at midnight UTC (customizable)**.\n   - To **run manually**, go to **GitHub Actions → Select Workflow → Run Workflow**.\n   - To **run on every push**, modify the workflow's `on:` section to:\n     ```yaml\n     on:\n       push:\n         branches:\n           - main\n     ```\n   \n6. **Wait for Processing**  \n   The time taken depends on the number of repositories and their sizes. Once completed, your `README.md` will be updated with the latest **lines of code breakdown**.\n\n7. **Ensure Placeholders Are Present**  \n   To allow automatic updates, your `README.md` must include the following placeholders:\n   ```\n    \u003c!-- LANGUAGES BREAKDOWN START --\u003e\n```\n[ LANGUAGES BREAKDOWN ]\n\nJavaScript   --\u003e 137,470 lines\nTypeScript   --\u003e 114,702 lines\nJSX          --\u003e 20,576 lines\nPHP          --\u003e 5,248 lines\nOthers       --\u003e 14,994 lines\n\n[ TOTAL LINES OF CODE: 292,990 ]\n```\n    \u003c!-- LANGUAGES BREAKDOWN END --\u003e\n   ```\n   The workflow will update the stats between these markers.  \n   *Remove `(STATIC EXAMPLE)` when adding it in your README, as it's just a placeholder. It's included here only to prevent automatic updates in this README.*\n\n### Configure languages\n\nThe workflow uses cloc **language names** (not file extensions).\n\n- **HIGHLIGHT_LANGS** → languages shown individually in the README; everything else is grouped under **Others**  \n- **IGNORE_LANGS** → languages dropped completely (not shown, not counted)\n\nEdit these in `.github/workflows/analyze-code.yml` under the job `env:` block:\n\n```yaml\nenv:\n  # Use cloc LANGUAGE NAMES (not extensions). Example: \"Vuejs Component\" for .vue, \"C#\" for C#\n  # HIGHLIGHT_LANGS: show these languages individually; everything else goes to \"Others\"\n  HIGHLIGHT_LANGS: \"JavaScript,TypeScript,JSX,Vuejs Component,PHP,C#\"\n\n  # IGNORE_LANGS: drop these languages entirely (not shown and not counted)\n  IGNORE_LANGS: \"JSON,HTML,CSS,SCSS,Sass,Markdown,SVG,XML,YAML,TOML,CSV,Text,Properties\"\n```\n\n### **Configure Language Detection**\nThe workflow asks cloc to exclude languages using cloc’s own filter, so totals match cloc’s `SUM`:\n\n```bash\ncloc . --json --report-file=../output/cloc-output.json --exclude-lang=\"${IGNORE_LANGS}\"\n```\n\nFor a complete list of language names supported by cloc, see the [cloc documentation](https://github.com/AlDanial/cloc).\n\n\n## Upcoming Features\n\nSoon, I'll be pushing changes to configure workflow execution based on a JSON configuration.  \nThis will allow you to:\n- Specify **which repositories** the script should run on by default.\n- Define **whether to run on all branches** or only specific branches for certain repositories.\n\nThis feature will be updated shortly.\n\n \n## Contributing\n \nContributions are welcome! Feel free to fork the repository, submit a PR, or open an issue.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farhamkhnz%2Fgithub-code-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farhamkhnz%2Fgithub-code-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farhamkhnz%2Fgithub-code-analyzer/lists"}