Skip to content

adding templates

adding templates #4

Workflow file for this run

name: Build, Deploy, and Analyze
on:
push:
branches:
- '**'
pull_request:
branches:
- master
workflow_dispatch:
jobs:
# Reuse setup-java.yml to set up Java environment
setup:
runs-on: self-hosted # Use self-hosted runner
uses: ./.github/workflows/setup-java.yml # Reusable workflow at the top level

Check failure on line 16 in .github/workflows/main.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/main.yml

Invalid workflow file

error parsing called workflow ".github/workflows/main.yml" -> "./.github/workflows/setup-java.yml" (source branch with sha:2560df27a50883b577ac532d9c40db10ecc99d84) : No event triggers defined in `on`
# Reuse build.yml to build the project with Maven and upload artifacts
build:
runs-on: self-hosted # Use self-hosted runner
needs: setup # Ensure setup job runs before build job
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Reuse setup-java.yml to set up Java in the build job
- name: Set up Java
uses: ./.github/workflows/setup-java.yml # Reuse the setup-java.yml
# Cache Maven dependencies
- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Build the project with Maven
- name: Build with Maven
run: mvn clean install
# Upload Artifacts with Versioning (Before running the .jar)
- name: Upload Artifacts with Versioning
uses: actions/upload-artifact@v4
with:
name: ${{ github.repository }}-${{ github.ref_name }}-${{ github.sha }} # Artifact name based on repo and branch
path: target/*.jar # Path to the built artifact (e.g., JAR file or other build outputs)
# Reuse sonarcloud-analysis.yml to run SonarCloud analysis
sonarcloud-analysis:
runs-on: self-hosted # Use self-hosted runner
needs: build # Ensure build job runs before sonarcloud-analysis job
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Reuse setup-java.yml to set up Java for SonarCloud analysis
- name: Set up Java
uses: ./.github/workflows/setup-java.yml # Reuse the setup-java.yml
# SonarCloud Analysis
- name: SonarCloud Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORG: your-organization # Replace with your actual SonarCloud organization
SONAR_HOST_URL: https://sonarcloud.io
run: |
mvn clean verify sonar:sonar \
-Dsonar.organization=${{ secrets.SONAR_ORG }} \
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }}