[CI] spotless 자동 apply 적용 #1
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: Android CI | |
on: | |
push: | |
branches: [ "develop" ] | |
pull_request: | |
types: [opened, synchronize, ready_for_review, edited] | |
branches: [ "develop", "refactor**", "fix**", "feat**", "feature**", "chore**", "test**" ] | |
jobs: | |
spotless_check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
- name: add local.properties | |
run: | | |
echo api.key=\"${{secrets.API_KEY}}\" > local.properties | |
- name: Cache Gradle Packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Spotless Check | |
run: ./gradlew spotlessCheck | |
spotless_apply: | |
needs: spotless_check | |
if: ${{ failure() }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
- name: add local.properties | |
run: | | |
echo api.key=\"${{secrets.API_KEY}}\" > local.properties | |
- name: Cache Gradle Packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: set git config | |
if: ${{ success() }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "$GITHUB_ACTOR" | |
git remote update | |
git fetch | |
git checkout origin/$GITHUB_HEAD_REF | |
- name: Spotless Apply | |
run: ./gradlew spotlessApply | |
- name: git commit and push | |
if: ${{ success() }} | |
run: | | |
git add . | |
git commit -m "Apply Spotless formatting" | |
git push origin HEAD:$GITHUB_HEAD_REF | |
build: | |
runs-on: ubuntu-latest | |
needs: spotless_check | |
if: ${{ success() }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
- name: add local.properties | |
run: | | |
echo api.key=\"${{secrets.API_KEY}}\" > local.properties | |
- name: Cache Gradle Packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew app:assembleDebug |