Auto-Update “Last Updated” Date on GitHub Push
This guide shows how to automatically update a Last updated date in your README.md every time you push code to GitHub — using GitHub Actions.
Why This Is Needed
GitHub does not automatically modify file contents on push.
So if you want a line like:
_Last updated: 2026-01-14_
to stay current, you need automation.
Final Result
After setup:
- Every push triggers a GitHub Action
- The README date updates automatically
- A commit is created by
github-actions
No manual edits required.
Step 1️⃣ Add a Placeholder in README
In your README.md (must be at repo root):
_Last updated: AUTO_
⚠️ This line must match exactly (case-sensitive).
Step 2️⃣ Create the GitHub Actions Folder
Create this structure:
.github/
└── workflows/
Step 3️⃣ Create the Workflow File
Create this file:
.github/workflows/update-date.yml
Paste the following:
name: Update README date
on:
push:
branches:
- main
- master
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Update date
run: |
DATE=$(date +"%Y-%m-%d")
sed -i "s/_Last updated:.*_/_Last updated: ${DATE}_/" README.md
- name: Commit and push
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add README.md
git commit -m "chore: auto update last updated date" || echo "No changes"
git push
Step 4️⃣ Enable Workflow Permissions (Very Important)
Go to:
Repo → Settings → Actions → General
Under Workflow permissions:
- ✅ Select Read and write permissions
- ✅ Click Save
Without this, the workflow will fail silently.
Step 5️⃣ Trigger the Workflow
The workflow runs only on new pushes.
Make a small change and push:
git add README.md
git commit -m "trigger workflow"
git push
Step 6️⃣ Verify
- Go to the Actions tab
- Open the latest workflow run
- Ensure all steps are ✅ green
- Check
README.md
You should now see:
_Last updated: 2026-01-14_
TL;DR
- GitHub doesn’t auto-update files
- GitHub Actions can
- A small workflow keeps your README date accurate
- Zero manual effort after setup
Top comments (0)