Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ci setup; Format the code automatically by CI #48

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/code_style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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
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 }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down