Add java example #2
Workflow file for this run
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: java-example | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- 'key-attestation/java-example/**' | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- 'key-attestation/java-example/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '8' | |
distribution: 'temurin' | |
cache: maven | |
- name: Check and Install Maven & Gradle | |
run: | | |
# Define an empty array to hold packages to be installed | |
packages_to_install=() | |
# Check if Maven is installed, add to array if not | |
if ! command -v mvn &> /dev/null; then | |
echo "Maven could not be found" | |
packages_to_install+=('maven') | |
else | |
echo "Maven is already installed" | |
fi | |
# Check if Gradle is installed, add to array if not | |
if ! command -v gradle &> /dev/null; then | |
echo "Gradle could not be found" | |
packages_to_install+=('gradle') | |
else | |
echo "Gradle is already installed" | |
fi | |
# If the array is not empty, update package lists and install packages | |
if [ ${#packages_to_install[@]} -ne 0 ]; then | |
echo "Installing packages..." | |
sudo apt update | |
for package in "${packages_to_install[@]}"; do | |
sudo apt install -y $package | |
done | |
fi | |
- name: Build with Maven | |
run: mvn -B package --file key-attestation/java-example/pom.xml | |
- name: Build with Gradle | |
run: gradle build -p key-attestation/java-example/ | |
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive | |
- name: Update dependency graph | |
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 | |
with: | |
directory: key-attestation/java-example |