Skip to content

upgrade GitHub Actions tasks (#794) #176

upgrade GitHub Actions tasks (#794)

upgrade GitHub Actions tasks (#794) #176

Workflow file for this run

name: cart service ci
on:
push:
branches: [ "main" ]
paths:
- "cart/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/cart-ci.yaml"
pull_request:
branches: [ "main" ]
paths:
- "cart/**"
- ".github/workflows/actions/action.yaml"
- ".github/workflows/cart-ci.yaml"
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 -DskipTests -pl cart -am
- name: Run Maven Test
run: mvn test -pl cart -am
- name: Unit Test Results
uses: dorny/test-reporter@v1
if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' && (success() || failure()) }}
with:
name: Cart-Service-Unit-Test-Results
path: "cart/**/surefire-reports/*.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 -pl cart -am
- 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: ./cart
push: true
tags: ghcr.io/nashtech-garage/yas-cart:latest