-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Duy Le Van
committed
Oct 9, 2024
1 parent
ddcf01d
commit a7deb00
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: recommendation service ci | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
paths: | ||
- "recommendation/**" | ||
- ".github/workflows/actions/action.yaml" | ||
- ".github/workflows/recommendation-ci.yaml" | ||
- "pom.xml" | ||
pull_request: | ||
branches: ["main"] | ||
paths: | ||
- "recommendation/**" | ||
- ".github/workflows/actions/action.yaml" | ||
- ".github/workflows/recommendation-ci.yaml" | ||
- "pom.xml" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Build: | ||
runs-on: ubuntu-latest | ||
env: | ||
FROM_ORIGINAL_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.ref == 'refs/heads/main' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- uses: ./.github/workflows/actions | ||
- name: Run Maven Build Command | ||
run: mvn clean install -pl recommendation -am | ||
- name: Run Maven Checkstyle | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
run: mvn checkstyle:checkstyle -pl recommendation -am -Dcheckstyle.output.file=recommendation-checkstyle-result.xml | ||
- name: Upload Checkstyle Result | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
uses: jwgmeligmeyling/checkstyle-github-action@master | ||
with: | ||
path: '**/recommendation-checkstyle-result.xml' | ||
- name: Test Results | ||
uses: dorny/test-reporter@v1 | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' && (success() || failure()) }} | ||
with: | ||
name: Recommendation-Service-Unit-Test-Results | ||
path: "recommendation/**/*-reports/TEST*.xml" | ||
reporter: java-junit | ||
- name: Analyze with sonar cloud | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
env: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -f recommendation | ||
- name: OWASP Dependency Check | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
uses: dependency-check/Dependency-Check_Action@main | ||
env: | ||
JAVA_HOME: /opt/jdk | ||
with: | ||
project: 'yas' | ||
path: '.' | ||
format: 'HTML' | ||
- name: Upload OWASP Dependency Check results | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: OWASP Dependency Check Report | ||
path: ${{github.workspace}}/reports | ||
- name: Add coverage report to PR | ||
uses: madrapps/[email protected] | ||
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} | ||
with: | ||
paths: ${{github.workspace}}/recommendation/target/site/jacoco/jacoco.xml | ||
token: ${{secrets.GITHUB_TOKEN}} | ||
min-coverage-overall: 80 | ||
min-coverage-changed-files: 60 | ||
title: 'Recommendation Coverage Report' | ||
update-comment: true | ||
- name: Log in to the Container registry | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker images | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./recommendation | ||
push: true | ||
tags: ghcr.io/nashtech-garage/yas-recommendation:latest |