#369 Add Docker build and GitHub action #690
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
permissions: | |
checks: write | |
pull-requests: write | |
name: Build and Test | |
on: | |
pull_request: | |
push: | |
workflow_dispatch: | |
jobs: | |
build-artifacts: | |
uses: ./.github/workflows/build-artifacts.yml | |
with: | |
# SonarQube requires JDK 17 or higher | |
java-version: '17' | |
run-sonar: true | |
post-build: | |
needs: build-artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: . | |
- name: 'Publish Test Results' | |
uses: EnricoMi/publish-unit-test-result-action/linux@v2 | |
if: always() | |
with: | |
files: | | |
**/build/test-results/**/*.xml | |
- name: JaCoCo Test Coverage Report | |
uses: PavanMudigonda/[email protected] | |
with: | |
coverage_results_path: "build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml" | |
coverage_report_name: Coverage | |
coverage_report_title: JaCoCo | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Collect state upon failure | |
if: failure() | |
run: | | |
echo "Git:" | |
git status | |
echo "Env:" | |
env | sort | |
echo "PWD:" | |
pwd | |
echo "Files:" | |
find * -ls | |
./gradlew javaToolchains | |
publish-docker-images: | |
needs: build-artifacts | |
permissions: | |
packages: write | |
contents: read | |
env: | |
DOCKER_USERNAME: ${{ github.repository_owner }} | |
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: '17' | |
- name: Cache Gradle Toolchain JDKs | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/jdks | |
key: "${{ runner.os }}-gradle-jdks" | |
restore-keys: ${{ runner.os }}-gradle-jdks | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: "${{ runner.os }}-gradle-caches }}" | |
restore-keys: ${{ runner.os }}-gradle-caches | |
- name: Execute Gradle build | |
run: ./gradlew dockerPush --scan --stacktrace | |
- name: Collect state upon failure | |
if: failure() | |
run: | | |
echo "Maven Repo:" | |
(cd $HOME && find .m2 -ls) | |
echo "Git:" | |
git status | |
echo "Env:" | |
env | sort | |
echo "PWD:" | |
pwd | |
echo "Files:" | |
find * -ls | |
./gradlew javaToolchains |