|
| 1 | +# Automated-Commit |
| 2 | + |
| 3 | +Automated-Commit is a simple and reusable example of a GitHub Actions workflow that periodically updates a file (`TIMESTAMP.txt`) with the current date and time and performs an automatic commit when it detects changes. |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This repository demonstrates how to automate routine tasks in a repository using GitHub Actions. The main workflow: |
| 8 | + |
| 9 | +- Clones the content from the `master` branch. |
| 10 | +- Updates (or creates) a `TIMESTAMP.txt` file with the current date and time. |
| 11 | +- Performs a commit if the file changed. |
| 12 | +- Pushes the commit back to the `master` branch. |
| 13 | + |
| 14 | +The goal is to serve as a template for automatic maintenance tasks (for example, periodic updates, status files, or similar scheduled tasks). |
| 15 | + |
| 16 | +## Features |
| 17 | + |
| 18 | +- Automatically executable on schedule (every 12 hours by default). |
| 19 | +- Allows manual execution from the Actions tab (`workflow_dispatch`). |
| 20 | +- Minimal configuration: Git name and email configured in the workflow. |
| 21 | + |
| 22 | +## Workflow Structure |
| 23 | + |
| 24 | +The workflow is defined in `.github/workflows/master.yml` and includes: |
| 25 | + |
| 26 | +- Triggers: `schedule` (cron every 12 hours) and `workflow_dispatch` for manual execution. |
| 27 | +- Main job: `update_commit` that runs on `ubuntu-latest`. |
| 28 | +- Steps: checkout, configure Git, update `TIMESTAMP.txt`, commit, and push. |
| 29 | +- Permissions: the workflow needs write permissions (default GITHUB_TOKEN usually suffices). |
| 30 | + |
| 31 | +## Requirements |
| 32 | + |
| 33 | +- A repository on GitHub. |
| 34 | +- GitHub Actions enabled in the repository. |
| 35 | + |
| 36 | +## Installation and Usage |
| 37 | + |
| 38 | +1. Use this repository as a template (click the "Use this template" button) or clone it locally. |
| 39 | +2. Open `.github/workflows/master.yml` and customize the configuration values (see "Configuration" section below). |
| 40 | +3. Push the changes to `master` to activate the workflow. |
| 41 | + |
| 42 | +### Manual Execution |
| 43 | + |
| 44 | +1. Go to the `Actions` tab in your repository. |
| 45 | +2. Select the `Automated-Commit` workflow. |
| 46 | +3. Click "Run workflow" and confirm the branch. |
| 47 | + |
| 48 | +## Configuration |
| 49 | + |
| 50 | +Edit `.github/workflows/master.yml` as needed: |
| 51 | + |
| 52 | +- Configure the `GIT_USER_EMAIL` and `GIT_USER_NAME` variables in Settings > Secrets and variables > Variables (optional; if not set, the default GitHub Actions account will be used). |
| 53 | +- Change the cron frequency if you need a different interval. |
| 54 | +- If you prefer, change the filename `TIMESTAMP.txt` to another target file. |
| 55 | + |
| 56 | +Security best practice: use the `GITHUB_TOKEN` provided by Actions for automatic pushes; avoid putting personal access tokens in plain text. |
| 57 | + |
| 58 | +## Common Customizations |
| 59 | + |
| 60 | +- Modify the cron: change the expression in `schedule` within the yml file. |
| 61 | +- Change the target file: update the filename that the script writes to. |
| 62 | +- Add tests or validations: insert additional steps before the commit to validate changes. |
| 63 | + |
| 64 | +## Contributing |
| 65 | + |
| 66 | +Contributions are welcome: |
| 67 | + |
| 68 | +1. Open an issue to discuss major changes. |
| 69 | +2. Send Pull Requests with clear descriptions. |
| 70 | + |
| 71 | +## Support |
| 72 | + |
| 73 | +For questions or issues, open an issue in the `Issues` section of the repository. |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +Thank you for using Automated-Commit. |
0 commit comments