mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
feat(ci): automation for blame ignore (#10295)
* feat(ci): automation for blame ignore * chore: Auto update by pre-commit hooks [skip changelog] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
49
.github/workflows/blame-ignore.yml
vendored
Normal file
49
.github/workflows/blame-ignore.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Blame Ignore Commit
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
blame-ignore:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false # Needed to bypass protection rules in Push changes
|
||||
|
||||
- name: Get last checked commit
|
||||
id: get_last_checked_commit
|
||||
run: |
|
||||
if [ -f .last-checked-commit ]; then
|
||||
LAST_CHECKED_COMMIT=$(cat .last-checked-commit)
|
||||
else
|
||||
LAST_CHECKED_COMMIT=$(git rev-list --max-parents=0 HEAD)
|
||||
fi
|
||||
echo "last_checked_commit=$LAST_CHECKED_COMMIT" >> $GITHUB_ENV
|
||||
|
||||
- name: Get new commit messages and hashes
|
||||
id: get_commits
|
||||
run: |
|
||||
git log ${{ env.last_checked_commit }}..HEAD --pretty=format:"%H %s" > commits.txt
|
||||
|
||||
- name: Check commit messages and update .git-blame-ignore-revs
|
||||
run: |
|
||||
while IFS= read -r line; do
|
||||
COMMIT_HASH=$(echo $line | cut -d' ' -f1)
|
||||
COMMIT_MESSAGE=$(echo $line | cut -d' ' -f2-)
|
||||
if [[ "$COMMIT_MESSAGE" == *"[blame ignore]"* ]]; then
|
||||
echo "$COMMIT_HASH" >> .git-blame-ignore-revs
|
||||
fi
|
||||
done < commits.txt
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git rev-parse HEAD > .last-checked-commit
|
||||
git add .
|
||||
git commit -m "chore: auto blame ignore"
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
|
||||
Reference in New Issue
Block a user