Skip to content

adding templates

adding templates #3

Workflow file for this run

name: Build, Deploy, and Analyze
on:
push:
branches:
- '**'
pull_request:
branches:
- master
workflow_dispatch:
jobs:
setup:
uses: ./.github/workflows/templates/setup-java.yml # Reuse setup-java workflow

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

View workflow run for this annotation

GitHub Actions / .github/workflows/main.yml

Invalid workflow file

invalid value workflow reference: workflows must be defined at the top level of the .github/workflows/ directory
secrets:
token: ${{ secrets.ACCESS_TOKEN }}
build:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Java
uses: ./.github/actions/setup-java-action # Reuse custom action
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: ./.github/actions/cache-maven-action # Reuse caching action
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Build with Maven
run: mvn clean install
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact-${{ github.sha }}
path: target/*.jar
sonarcloud-analysis:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Java
uses: ./.github/actions/setup-java-action # Reuse setup-java action
with:
java-version: '17'
distribution: 'temurin'
- name: SonarCloud Analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_ORG: your-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 }}