Skip to content

Configuring GitHub package Maven repos. #32

Configuring GitHub package Maven repos.

Configuring GitHub package Maven repos. #32

Workflow file for this run

on:
push:
branches:
- release/*
- develop
- feature/*
pull_request:
types: [opened, synchronize, reopened]
branches:
- release/*
- develop
- feature/*
merge_group:
workflow_dispatch:
name: Build and Test Java
jobs:
build-artifacts:
name: Build and Test Artifacts
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
packages: write
env:
BUILD_SNAPSHOT: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
(github.ref_name == 'develop' || startsWith(github.ref_name, 'release/')) }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
submodules: recursive
filter: tree:0
# -------------------------
# Java Environment Setup
# -------------------------
- name: Set up Maven
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1
with:
maven-version: 3.9.8
- name: Set up JDK 11
uses: actions/setup-java@5896cecc08fd8a1fbdfaf517e29b571164b031f7
with:
java-version: 11
distribution: 'temurin'
cache: maven
# - name: Cache Maven packages
# uses: actions/cache@v3
# with:
# path: ~/.m2
# key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
# restore-keys: ${{ runner.os }}-m2
# - uses: s4u/maven-settings-action@7802f6aec16c9098b4798ad1f1d8ac75198194bd
# with:
# servers: |
# [{
# "id": "github",
# "configuration": {
# "username": "GITHUB_ACTOR",
# "password": "GITHUB_TOKEN"
# }
# }]
- name: Initialize CodeQL
if: github.event_name == 'push'
uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c
with:
languages: java
# -------------------------
# Maven Build
# -------------------------
- id: build-test-deploy
name: Build, Test and DEPLOY SNAPSHOT Code
if: ${{ env.BUILD_SNAPSHOT == 'true' }}
run: |
mvn -B -e --batch-mode -Prelease deploy -Dmaven.deploy.skip=releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Test Code
if: ${{ steps.build-test-deploy.outcome == 'skipped' }}
run: |
mvn -B -e -Prelease -Preporting install
- name: Perform CodeQL Analysis
if: github.event_name == 'push'
uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c
with:
upload: ${{ github.ref_name == 'develop' && 'always' || 'never' }}
- name: Test Website
run: |
# this needs to be run as a second build to ensure source is fully generated by the previous step
mvn -B -e -Prelease install site site:stage