https://github.com/4uffin/daily-count
A simple, self-managing system to automatically track a daily streak or continuous counter. Using Python and GitHub Actions.
https://github.com/4uffin/daily-count
actions automated automated-testing automation daily-tracker experiment github github-actions python python3 yaml yml
Last synced: about 2 months ago
JSON representation
A simple, self-managing system to automatically track a daily streak or continuous counter. Using Python and GitHub Actions.
- Host: GitHub
- URL: https://github.com/4uffin/daily-count
- Owner: 4uffin
- Created: 2025-09-30T04:54:07.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-04-28T15:33:12.000Z (about 2 months ago)
- Last Synced: 2026-04-28T23:38:46.006Z (about 2 months ago)
- Topics: actions, automated, automated-testing, automation, daily-tracker, experiment, github, github-actions, python, python3, yaml, yml
- Language: Python
- Homepage: https://4uffin.github.io/daily-count/
- Size: 142 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[](https://github.com/features/actions)
[](https://www.python.org/downloads/)

# **📅 Automated Daily Log Tracker**
This repository contains a simple, self-managing system to automatically track a daily streak or continuous counter. It runs once per day using **GitHub Actions**, executes a Python script to calculate the current day count, and commits a new, timestamped log file back to the repository.
The resulting files are named with the format: ```Day-X_YYYY-MM-DD.txt```.
## **📂 Project Structure**
```
├── .github/
│ └── workflows/
│ └── daily_run.yml # GitHub Action configuration
├── daily_logs/ # Automated output folder
│ └── Day-1_2025-09-29.txt
│ └── Day-2_2025-09-30.txt
└── daily_counter.py # The core Python logic
```
## **🚀 Setup and Installation**
Follow these steps to deploy the tracker in your own GitHub repository.
### **1. Repository Preparation**
1. **Create Repository:** Start a new GitHub repository.
2. **Add Files:** Add the ```daily_counter.py``` script and the ```.github/workflows/daily_run.yml``` file to the root of your repository.
3. **(Optional but Recommended):** Create the empty directory ```daily_logs``` locally and add a placeholder file (e.g., ```.gitkeep```) to ensure the directory is tracked by Git, though the Python script will create it if needed.
### **2. GitHub Action Configuration**
The GitHub Action is configured to run automatically, but you must ensure it has the necessary permissions to commit the files.
**No additional secrets are needed.** The action uses the built-in ```GITHUB_TOKEN``` which already has the permissions required by the workflow file ```(permissions: contents: write)```.
### **3. Execution Schedule**
The workflow is currently scheduled to run every day at **midnight UTC** ```(0 0 * * *)```.
If you want to manually trigger the first run or test the process:
1. Go to the **Actions** tab in your repository.
2. Select the **Daily Log Creator** workflow.
3. Click the **Run workflow** dropdown and select the ```main``` branch.
## **⚙️ How It Works**
The system ensures **idempotence** (it won't create duplicate files if run multiple times in one day).
1. **Daily Trigger:** GitHub runs the ```daily_run.yml``` job at the scheduled time.
2. **Count Calculation:** ```daily_counter.py``` looks inside the ```daily_logs/``` folder and counts all existing ```.txt``` files. This count is used to determine the sequential **Day-X** number.
3. **Duplicate Check:** The script generates the expected filename (e.g., ```Day-15_2026-03-05.txt```) and checks if it already exists.
* **If file exists:** The script exits with a ```non-zero exit code (1)```, and the commit step is skipped.
* **If file is new:** The script creates the file and exits with a ```zero exit code (0)```.
4. **Commit:** The GitHub Action sees the ```success status (0)```, stages the new file ```(git add daily_logs/*.txt)```, commits it, and pushes the change to the ```main``` branch.
## **🐍 Python Dependencies**
The core logic relies solely on the Python Standard Library.
| Module | Purpose |
| :---- | :---- |
| ```datetime``` | Used to get the current date ```(YYYY-MM-DD)```. |
| ```pathlib``` | Used for reliable, cross-platform file and directory manipulation. |
| ```os```, ```sys``` | Used for interacting with the system exit codes (crucial for GitHub Actions). |