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.
This repository demonstrates how to automate routine tasks in a repository using GitHub Actions. The main workflow:
- Clones the content from the
masterbranch. - Updates (or creates) a
TIMESTAMP.txtfile with the current date and time. - Performs a commit if the file changed.
- Pushes the commit back to the
masterbranch.
The goal is to serve as a template for automatic maintenance tasks (for example, periodic updates, status files, or similar scheduled tasks).
- Automatically executable on schedule (every 12 hours by default).
- Allows manual execution from the Actions tab (
workflow_dispatch). - Minimal configuration: Git name and email configured in the workflow.
The workflow is defined in .github/workflows/master.yml and includes:
- Triggers:
schedule(cron every 12 hours) andworkflow_dispatchfor manual execution. - Main job:
update_committhat runs onubuntu-latest. - Steps: checkout, configure Git, update
TIMESTAMP.txt, commit, and push. - Permissions: the workflow needs write permissions (default GITHUB_TOKEN usually suffices).
- A repository on GitHub.
- GitHub Actions enabled in the repository.
- Use this repository as a template (click the "Use this template" button) or clone it locally.
- Open
.github/workflows/master.ymland customize the configuration values (see "Configuration" section below). - Push the changes to
masterto activate the workflow.
- Go to the
Actionstab in your repository. - Select the
Automated-Commitworkflow. - Click "Run workflow" and confirm the branch.
Edit .github/workflows/master.yml as needed:
- Configure the
GIT_USER_EMAILandGIT_USER_NAMEvariables in Settings > Secrets and variables > Variables (optional; if not set, the default GitHub Actions account will be used). - Change the cron frequency if you need a different interval.
- If you prefer, change the filename
TIMESTAMP.txtto another target file.
Security best practice: use the GITHUB_TOKEN provided by Actions for automatic pushes; avoid putting personal access tokens in plain text.
- Modify the cron: change the expression in
schedulewithin the yml file. - Change the target file: update the filename that the script writes to.
- Add tests or validations: insert additional steps before the commit to validate changes.
Contributions are welcome:
- Open an issue to discuss major changes.
- Send Pull Requests with clear descriptions.
For questions or issues, open an issue in the Issues section of the repository.
Thank you for using Automated-Commit.