Maven Build and Deploy #4
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: Maven Build and Deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Unit Tests | |
run: mvn clean test | |
- name: Check Formatting | |
run: mvn spotless:check | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.event_name == 'workflow_dispatch' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '11' | |
- name: Set up Maven settings for GitHub Packages | |
run: | | |
mkdir -p ~/.m2 | |
echo "<settings> | |
<servers> | |
<server> | |
<id>github</id> | |
<username>${{ secrets.MAVEN_USERNAME }}</username> | |
<password>${{ secrets.MAVEN_PASSWORD }}</password> | |
</server> | |
</servers> | |
</settings>" > ~/.m2/settings.xml | |
- name: Deploy with Maven | |
run: mvn deploy |