Update README.md #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Clean Commit Message | |
on: | |
push: | |
branches: | |
- main # Adjust to your branch name if different | |
jobs: | |
clean-commit-message: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch full history to make amends | |
- name: Amend commit message to remove '- LeetSync' | |
run: | | |
# Get the latest commit message | |
$commitMessage = git log -1 --pretty=%B | |
# Check if the commit message contains '- LeetSync' | |
if ($commitMessage -match " - LeetSync") { | |
# Remove '- LeetSync' from the commit message | |
$newCommitMessage = $commitMessage -replace " - LeetSync", "" | |
# Amend the commit message | |
git commit --amend -m $newCommitMessage | |
# Force push the amended commit | |
git push origin main --force | |
} else { | |
Write-Output "No ' - LeetSync' in commit message, no changes made." | |
} | |
env: | |
GIT_AUTHOR_NAME: GitHub Actions | |
GIT_AUTHOR_EMAIL: actions@github.com | |
GIT_COMMITTER_NAME: GitHub Actions | |
GIT_COMMITTER_EMAIL: actions@github.com |