ci: blame ignore only commits when ignore-revs is modified

This commit is contained in:
Constrat
2024-12-16 00:25:20 +01:00
parent 20ac6abc9e
commit 10beff8e10
2 changed files with 15 additions and 8 deletions

View File

@@ -45,4 +45,3 @@ bc3ad67a02cb3b8e154c06955cf17091c4265000
# as they are automatically appended
# --------------------------------------------------- #
f7772bc814c52f9a5e65af02404cf54b70fe0a32

View File

@@ -1,8 +1,8 @@
name: Git Blame Ignore
on:
# schedule:
# - cron: "45 21 * * *" # Runs daily at 22:00 UTC
schedule:
- cron: "45 21 * * *" # Runs daily at 22:00 UTC
workflow_dispatch:
jobs:
@@ -16,15 +16,18 @@ jobs:
fetch-depth: 0
persist-credentials: false # Needed to bypass protection rules in Push changes
- name: Get last checked commit
- name: Check blame
id: check_changes
run: |
LAST_CHECKED_COMMIT=$(cat .github/.last-blame-ignore-commit 2>/dev/null || git rev-list --max-parents=0 HEAD)
echo "LAST_CHECKED_COMMIT=$LAST_CHECKED_COMMIT" >> $GITHUB_ENV
- name: Process commits and update blame ignore list
git log $LAST_CHECKED_COMMIT..HEAD --pretty=format:"%H %s" --grep="\[blame ignore\]" | awk '{print $1}' >> .git-blame-ignore-revs
git diff --quiet .git-blame-ignore-revs
- name: Commit and Push changes
if: ${{ steps.check_changes.outcome == 'failure' }}
run: |
git log ${{ env.LAST_CHECKED_COMMIT }}..HEAD --pretty=format:"%H %s" --grep="\[blame ignore\]" | awk '{print $1}' >> .git-blame-ignore-revs
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
@@ -34,7 +37,12 @@ jobs:
git commit -m "chore: auto blame ignore" -m "[skip changelog]"
- name: Push changes
if: ${{ steps.check_changes.outcome == 'failure' }}
uses: ad-m/github-push-action@master
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.MAA_RESOURCE_SYNC }}
- name: Stop if no changes
if: ${{ steps.check_changes.outcome == 'success' }}
uses: andymckay/cancel-action@0.5