-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (33 loc) · 1.15 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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: [email protected]
GIT_COMMITTER_NAME: GitHub Actions
GIT_COMMITTER_EMAIL: [email protected]