Update github action #127
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pr_build | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
formatCode: | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.actor, 'github-actions[bot]') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.ACTION_TOKEN }} | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Set Git Username | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- uses: sbt/setup-sbt@v1 | |
- name: Format code | |
run: | | |
sbt scalafmtAll | |
- name: Check for changes | |
run: | | |
if git diff-index --quiet HEAD; then | |
echo "IS_CHANGED=false" >> $GITHUB_ENV | |
else | |
echo "IS_CHANGED=true" >> $GITHUB_ENV | |
fi | |
- name: Push code if format is needed | |
if: ${{ env.IS_CHANGED == 'true' }} | |
run: | | |
git add --all | |
git commit -m ":recycle: format code" | |
git push origin ${{ github.head_ref }} | |
build: | |
needs: formatCode | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- uses: sbt/setup-sbt@v1 | |
- name: Clean and Compile | |
run: sbt clean compile | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- uses: sbt/setup-sbt@v1 | |
- name: Test | |
run: sbt test | |