name: Deploy Snapshot

on:
  push:
    branches:
      - main

jobs:
  gradle:
    runs-on: ubuntu-latest
    if: github.repository == 'detekt/detekt' && !contains(github.event.head_commit.message, 'ci skip')
    steps:
    - name: Checkout Repo
      uses: actions/checkout@v2

    - name: Setup Java
      uses: actions/setup-java@v2
      with:
        java-version: 17
        distribution: 'temurin'

    - name: Build detekt
      uses: gradle/gradle-build-action@v2
      with:
        arguments: build

    - name: Deploy Snapshot
      uses: gradle/gradle-build-action@v2
      env:
        MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }}
        MAVEN_CENTRAL_PW: ${{ secrets.MAVEN_CENTRAL_PW }}
      with:
        arguments: publishAllPublicationsToSonatypeSnapshotRepository -Dsnapshot=true --stacktrace
