diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4544d83..698d948 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -48,36 +48,4 @@ jobs: uses: actions/upload-artifact@v5.0.0 with: name: jacoco-report - path: target/site/jacoco - - format: - name: Format Code - permissions: - contents: write - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v5.0.0 - with: - ref: ${{ github.event.pull_request.head.ref}} - fetch-depth: 0 - - - name: Instalar Java 25 - uses: actions/setup-java@v5.0.0 - with: - distribution: "temurin" - java-version: 25 - - name: Formatar código com Spotless - run: ./mvnw spotless:apply - - - name: Faz um commit e push das mudanças - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add . - if ! git diff --staged --quiet; then - git commit -m "Aplica formatação do spotless" - git push - else - echo "Nenhuma mudança de formatação necessária." - fi + path: target/site/jacoco \ No newline at end of file diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml new file mode 100644 index 0000000..d221517 --- /dev/null +++ b/.github/workflows/spotless.yml @@ -0,0 +1,43 @@ +name: Format Code + +on: + pull_request_review: + types: [submitted] + +permissions: + contents: write + pull-requests: write + +jobs: + format: + if: github.event.review.state == 'approved' + runs-on: ubuntu-latest + + steps: + - name: Checkout na branch do Pull Request + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 0 + + - name: Instalar Java 25 + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 25 + + - name: Aplicar Spotless + run: ./mvnw spotless:apply + + - name: Commit e push se houver mudanças + run: | + if [[ -n "$(git status --porcelain)" ]]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "chore: apply spotless formatting" + git push + else + echo "Nenhuma mudança de formatação." + fi \ No newline at end of file diff --git a/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java b/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java index 3529253..596d63e 100644 --- a/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java +++ b/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java @@ -35,7 +35,7 @@ public ResponseEntity findById(@PathVariable Long id) { return ResponseEntity.ok(reminderService.findById(id)); } - @PostMapping() + @PostMapping public ResponseEntity create(@RequestBody @Valid CreateReminderRequestDTO dto) { return ResponseEntity.status(HttpStatus.CREATED).body(reminderService.create(dto)); }