Skip to content

Commit

Permalink
try it
Browse files Browse the repository at this point in the history
  • Loading branch information
THWiseman committed Dec 8, 2023
1 parent 532b2ca commit e2bf9a4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/scalafmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ name: 'Scalafmt'

# This GitHub Action runs the ScalaFmt linting tool on the entire codebase.
# It fails if any files are not formatted properly.
# If it is triggered by someone commenting 'scalafmt' on a PR, it will first format, commit, and push formatted code
# to the branch.

run-name: ${{ format('Scalafmt on {0}', github.ref_name) }}

on:
workflow_dispatch:
push:
issue_comment:
types:
- created

permissions:
contents: read
Expand All @@ -23,6 +28,26 @@ jobs:
- uses: ./.github/set_up_cromwell_action
with:
cromwell_repo_token: ${{ secrets.BROADBOT_GITHUB_TOKEN }}
- name: Check for ScalaFmt Comment
run: |
if [[ "${{ github.event_name }}" == "issue_comment" && "${{ github.event.comment.body }}" == *"scalafmt"* ]]; then
echo "::set-output name=comment-triggered::true"
echo "::set-output name=comment-author-email::${{ github.event.comment.user.login }}@users.noreply.github.com"
echo "::set-output name=comment-author-name::${{ github.event.comment.user.login }}"
else
echo "::set-output name=comment-triggered::false"
fi
shell: bash
- name: Run ScalaFmt
run: |
if [[ ${{ steps.check-comment.outputs.comment-triggered }} == 'true' ]]; then
echo "PR Comment Detected. Formatting, committing, and pushing formatted scala code.
sbt scalaFmtAll
git config --global user.email "${{ steps.check-comment.outputs.comment-author-email }}"
git config --global user.name "${{ steps.check-comment.outputs.comment-author-name }}"
git add .
git commit -m "Auto-format code with ScalaFmt"
git push origin ${{ github.ref }}
fi
sbt scalafmtCheckAll
working-directory: ${{ github.workspace }}

0 comments on commit e2bf9a4

Please sign in to comment.