.github/workflows/build.yml #119
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
on: | |
push: | |
branches: [ main ] | |
# Publish semver tags as releases. | |
tags: [ 'v*.*.*' ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: '0 20 * * 5' | |
jobs: | |
check-code-quality: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
cache: "maven" | |
- name: Check Pom Sort | |
run: mvn -B sortpom:verify | |
- name: Check File Formatting | |
run: mvn -B fmt:check | |
run-code-tests: | |
needs: check-code-quality | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
cache: "maven" | |
- name: Test Code | |
run: mvn -B verify | |
deploy-artifact: | |
needs: [check-code-quality, run-code-tests] | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "temurin" | |
cache: "maven" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }} | |
name: Build and Deploy Image | |
run: mvn -B clean install jib:build | |
- if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
name: Build and Deploy Tag Image | |
run: mvn -B clean install jib:build -P release |