diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 7b12b04820..5da8bbc8a4 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -45,4 +45,3 @@ bc3ad67a02cb3b8e154c06955cf17091c4265000 # as they are automatically appended # --------------------------------------------------- # f7772bc814c52f9a5e65af02404cf54b70fe0a32 - diff --git a/.github/workflows/blame-ignore.yml b/.github/workflows/blame-ignore.yml index 4cba4843d3..13f46ccd2e 100644 --- a/.github/workflows/blame-ignore.yml +++ b/.github/workflows/blame-ignore.yml @@ -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