diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index edaff914..73a33e06 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -5,16 +5,43 @@ on: - main - feature/ci_setup pull_request: + paths: + - '.github/workflows/code_style.yml' + - '**/*.kt' + - '**/*.kts' jobs: check-code-style: runs-on: ubuntu-latest + env: + BRANCH_REF: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }} steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: distribution: 'corretto' java-version: '17' + + - name: Format code style + run: | + ./gradlew ktlintFormat + + - name: Commit files changed by ktlintFormat + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + git add . + git diff --quiet && git diff --staged --quiet || git commit -m "Apply ktlint formatting" + - name: Check code style shell: bash - run: ./gradlew ktlintCheck \ No newline at end of file + run: ./gradlew ktlintCheck + + - name: Pull latest changes + run: git pull --rebase origin ${BRANCH_REF} + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }} \ No newline at end of file diff --git a/README.md b/README.md index 2350c9f4..07215dfc 100644 --- a/README.md +++ b/README.md @@ -423,6 +423,8 @@ To add to a multiplatform project, add the dependency to the common source-set: ```kotlin repositories { mavenCentral() + // Desktop target has to add this repo + maven("https://jogamp.org/deployment/maven") } kotlin {