{"id":27654003,"url":"https://github.com/miguel07alm/dcs","last_synced_at":"2025-04-24T05:17:05.976Z","repository":{"id":287585610,"uuid":"964876600","full_name":"Miguel07Alm/dcs","owner":"Miguel07Alm","description":"A tool that monitors a local Git repository, generates AI-powered summaries of recent commits (daily, weekly, or monthly), and sends them to a Discord channel. Includes robust error handling and optional email notifications for critical failures.","archived":false,"fork":false,"pushed_at":"2025-04-12T20:40:43.000Z","size":34,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T05:16:48.930Z","etag":null,"topics":["ai","automation","cronjob","discord","gemini"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miguel07Alm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-04-12T00:16:07.000Z","updated_at":"2025-04-23T09:16:14.000Z","dependencies_parsed_at":"2025-04-12T17:26:29.006Z","dependency_job_id":"3c0d4d0e-ad9c-41af-a7a5-53995f39a532","html_url":"https://github.com/Miguel07Alm/dcs","commit_stats":null,"previous_names":["miguel07alm/dcs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguel07Alm%2Fdcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguel07Alm%2Fdcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguel07Alm%2Fdcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miguel07Alm%2Fdcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miguel07Alm","download_url":"https://codeload.github.com/Miguel07Alm/dcs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566522,"owners_count":21451234,"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":["ai","automation","cronjob","discord","gemini"],"created_at":"2025-04-24T05:17:05.231Z","updated_at":"2025-04-24T05:17:05.970Z","avatar_url":"https://github.com/Miguel07Alm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DCS - Discord Commit Summarizer\n\nA tool that monitors a local Git repository, generates AI-powered summaries of recent commits (daily, weekly, or monthly), and sends them to a Discord channel. Includes robust error handling and optional email notifications for critical failures.\n\n## Motivation\n\nKeeping a community updated with the latest project developments often involves manually reading through Git commits and crafting announcements. This tool was born out of the desire to automate this process, making it effortless to generate clear, engaging updates from commit history and share them directly where the community gathers, like Discord.\n\n## Features\n\n*   Monitors a specified local Git repository.\n*   Fetches commits based on a configurable frequency (`daily`, `weekly`, `monthly`).\n*   Uses the Gemini API (via the OpenAI library interface) to generate user-friendly summaries focused on user impact and new capabilities, styled for Discord announcements.\n*   Includes project context (reads the first 1000 characters of the repository's `README.md`) in the AI prompt for more relevant summaries.\n*   Provides a basic commit list fallback if the AI summarization fails.\n*   Sends summaries to a specified Discord webhook URL.\n*   Automatically splits long messages to comply with Discord character limits.\n*   Logs detailed run information to timestamped markdown files in the `logs/` directory.\n*   Robust error handling for configuration issues, Git operations, AI API calls, and Discord sending.\n*   Optional email notifications via SMTP (configurable for Gmail or other providers) for critical script failures, making it suitable for monitoring automated runs (e.g., via cron).\n\n## Setup\n\n1.  **Clone the repository:**\n    ```bash\n    git clone \u003cyour-repo-url\u003e\n    cd dcs\n    ```\n2.  **Create and activate a virtual environment:**\n    ```bash\n    # Using venv (standard library)\n    python -m venv .venv\n    source .venv/bin/activate # On Windows use `.venv\\Scripts\\activate`\n\n    # Or using uv (if installed)\n    uv venv\n    source .venv/bin/activate\n    ```\n3.  **Install dependencies:**\n    ```bash\n    # Using pip\n    pip install -r requirements.txt \n    # Or if you have configured pyproject.toml for the project:\n    # pip install .\n\n    # Or using uv\n    uv pip install -r requirements.txt\n    # Or uv pip install .\n    ```\n4.  **Configure environment variables:**\n    *   Copy the example environment file:\n        ```bash\n        cp .env.example .env\n        ```\n    *   Edit the `.env` file and fill in the required values:\n        *   `DISCORD_WEBHOOK_URL`: Your Discord channel webhook URL.\n        *   `GIT_REPO_PATH`: The absolute path to the local Git repository you want to monitor.\n        *   `GEMINI_API_KEY`: Your API key for the Google Gemini model.\n        *   (Optional) `SUMMARY_FREQUENCY`: Set to `daily`, `weekly` (default), or `monthly`.\n        *   (Optional) Email Notification Settings: If you want email alerts on failure:\n            *   Set `ENABLE_EMAIL_NOTIFICATION=\"true\"`.\n            *   Configure `SMTP_SERVER`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD`, `EMAIL_SENDER`, `EMAIL_RECEIVER`.\n            *   **Important for Gmail:** Use `smtp.gmail.com` and port `587`. If you have 2-Factor Authentication enabled on your Google account, you **must** generate an \"App Password\" and use that for `SMTP_PASSWORD`. Do not use your regular Google account password.\n\n## Usage\n\n*   **Manual Run:**\n    Execute the script directly from the project root:\n    ```bash\n    python src/dcs/main.py\n    \n    # Or using directly\n    dcs\n    ```\n*   **Automated Run (Cron Job):**\n    Set up a cron job to run the script automatically. Edit your crontab (`crontab -e`) and add an entry like this (example runs daily at 3:00 AM):\n    ```cron\n    0 3 * * * /usr/bin/python /path/to/your/dcs/src/dcs/main.py \u003e\u003e /path/to/your/dcs/logs/cron.log 2\u003e\u00261\n    ```\n    *   **Important:**\n        *   Replace `/usr/bin/python` with the actual path to the python executable *within your virtual environment* (e.g., `/path/to/your/dcs/.venv/bin/python`) or ensure the script runs with the correct environment activated.\n        *   Replace `/path/to/your/dcs/` with the absolute path to the project directory.\n        *   Ensure the user running the cron job has the necessary permissions and environment variables set (cron jobs often run with a minimal environment; you might need to source variables or use absolute paths).\n\n## Logging\n\nCheck the `logs/` directory within the project folder. Each script run creates a detailed markdown file (e.g., `dcs_run_YYYYMMDD_HHMMSS.md`) containing information about the execution steps, fetched commits, AI prompts/responses, and any errors encountered.\n\n## GitHub Action\n\nYou can also use DCS as a GitHub Action to automatically generate summaries from your GitHub repository and post them to Discord.\n\n### Setting up the GitHub Action\n\n1. **Add required secrets to your GitHub repository:**\n   - Go to your repository's Settings \u003e Secrets and variables \u003e Actions\n   - Add the following secrets:\n     - `DISCORD_WEBHOOK_URL`: Your Discord channel webhook URL\n     - `GEMINI_API_KEY`: Your API key for the Google Gemini model\n\n2. **Use as a workflow in your repository:**\n\n   Create a file at `.github/workflows/discord-summary.yml` with the following content:\n\n   ```yaml\n   name: Discord Commit Summary\n\n   on:\n     schedule:\n       - cron: '0 12 * * 5'  # Run every Friday at 12:00 UTC\n     workflow_dispatch:  \n\n   jobs:\n     summarize:\n       uses: miguel07alm/dcs/.github/workflows/dcs-action.yml@main\n       with:\n         frequency: weekly  # Options: daily, weekly, monthly\n         send_empty_summary: false  # Whether to send a summary when no commits are found\n       secrets:\n         DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}\n         GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}\n   ```\n\n3. **Customize as needed:**\n   - Adjust the schedule to your preferred frequency\n   - Change the `frequency` parameter to match your needs\n\n### Manual Trigger\n\nYou can also manually trigger the workflow by:\n1. Going to your repository's \"Actions\" tab\n2. Selecting the \"Discord Commit Summary\" workflow\n3. Clicking \"Run workflow\"\n4. Optionally adjusting the parameters before running\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguel07alm%2Fdcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiguel07alm%2Fdcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguel07alm%2Fdcs/lists"}