Skip to content

Commit d3a74be

Browse files
authored
Update maven.yml
1 parent 71de57d commit d3a74be

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

.github/workflows/maven.yml

+50-20
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,75 @@
1-
name: maven-build
1+
name: Build & Deploy
22
on:
33
push:
4-
branches:
5-
- master
4+
branches: [master]
5+
paths-ignore:
6+
- '**.md'
7+
- '.gitignore'
8+
- 'LICENSE'
69
pull_request:
710
types: [opened, synchronize, reopened]
11+
paths-ignore:
12+
- '**.md'
13+
- '.gitignore'
14+
- 'LICENSE'
15+
816
jobs:
917
build:
10-
name: Build, analyse, publish
18+
name: Build, Analyze & Deploy
1119
runs-on: ubuntu-latest
20+
21+
permissions:
22+
contents: write # for GitHub Pages deployment
23+
pages: write
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: true
28+
1229
steps:
1330
- uses: actions/checkout@v4
1431
with:
15-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
32+
fetch-depth: 0 # Required for SonarQube analysis
33+
1634
- name: Set up JDK 17
1735
uses: actions/setup-java@v4
1836
with:
1937
java-version: 17
2038
distribution: 'temurin'
39+
cache: 'maven' # Enables built-in Maven dependency caching
40+
2141
- name: Cache SonarQube packages
2242
uses: actions/cache@v4
2343
with:
2444
path: ~/.sonar/cache
25-
key: ${{ runner.os }}-sonar
26-
restore-keys: ${{ runner.os }}-sonar
27-
- name: Cache Maven packages
28-
uses: actions/cache@v4
29-
with:
30-
path: ~/.m2
31-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32-
restore-keys: ${{ runner.os }}-m2
45+
key: ${{ runner.os }}-sonar-${{ hashFiles('**/pom.xml') }}
46+
restore-keys: |
47+
${{ runner.os }}-sonar-
48+
3349
- name: Build and analyze
3450
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3552
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
36-
run: mvn -B -Puber-jar verify javadoc:javadoc org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=micycle1_PTS
37-
- uses: actions/upload-artifact@v4
53+
run: |
54+
mvn -B -Puber-jar verify \
55+
javadoc:javadoc \
56+
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
57+
-Dsonar.projectKey=micycle1_PTS \
58+
-Dsonar.java.source=17 \
59+
-Dmaven.test.failure.ignore=false
60+
61+
- name: Upload JAR artifact
62+
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
63+
uses: actions/upload-artifact@v4
3864
with:
39-
name: PGS Uber-jar
65+
name: PGS-uber-jar
4066
path: target/*.jar
41-
- name: Publish Javadocs
42-
uses: JamesIves/github-pages-deploy-action@4
67+
if-no-files-found: error
68+
retention-days: 90
69+
70+
- name: Deploy Javadocs to GitHub Pages
71+
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
72+
uses: JamesIves/github-pages-deploy-action@v4
4373
with:
44-
branch: gh-pages # The branch the action should deploy to.
45-
folder: target/reports/apidocs # The folder the action should deploy.
74+
branch: gh-pages
75+
folder: target/site/apidocs

0 commit comments

Comments
 (0)