Skip to content

[gh-bot] Update .git-blame-ignore-revs to exclude bot commit #91

[gh-bot] Update .git-blame-ignore-revs to exclude bot commit

[gh-bot] Update .git-blame-ignore-revs to exclude bot commit #91

Workflow file for this run

name: Scalafmt
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
scalafmt:
# Do not run on PRs / pushes from the bot (commit marked with [gh-bot])
if: ${{ !contains(github.event.head_commit.message, '[gh-bot]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch full history for proper blame tracking
token: ${{ secrets.REPO_TOKEN }} # Use the token for authentication
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Install Coursier
run: |
curl -fLo cs https://git.io/coursier-cli-linux && chmod +x cs
- name: Install Scalafmt
run: |
./cs install scalafmt
- name: Run Scalafmt
run: |
/home/runner/.local/share/coursier/bin/scalafmt --non-interactive --diff-branch main
- name: Commit and push changes
if: ${{ github.ref == 'refs/heads/main' }} # Only commit on main branch
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --quiet && git diff --cached --quiet || git commit -m "[gh-bot] Apply Scalafmt formatting"
echo "$(git rev-parse HEAD)" >> .git-blame-ignore-revs
git add .git-blame-ignore-revs
git commit -m "[gh-bot] Update .git-blame-ignore-revs to exclude bot commit"
git push https://${{ secrets.REPO_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main