name: Deploy Snapshot

on:
  push:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    if: ${{ github.repository == 'biojava/biojava-legacy' }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'temurin'
          server-id: sonatype-nexus-snapshots
          server-username: MAVEN_USERNAME
          server-password: MAVEN_PASSWORD
      - uses: actions/cache@v2
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2
      - env:
          MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
          MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
        run: mvn --batch-mode -DskipTests=true deploy
