Skip to content

Commit 757599f

Browse files
authored
feat: refactor CI workflows to use reusable build configuration (#181)
1 parent a6fc93e commit 757599f

File tree

3 files changed

+40
-56
lines changed

3 files changed

+40
-56
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,8 @@ env:
99

1010
jobs:
1111
build:
12-
name: Build and analyze
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v6
16-
with:
17-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18-
- name: Set up JDK 24
19-
uses: actions/setup-java@v5
20-
with:
21-
distribution: 'temurin' # See 'Supported distributions' for available options
22-
java-version: '24'
23-
- name: Cache SonarCloud packages
24-
uses: actions/cache@v5
25-
with:
26-
path: ~/.sonar/cache
27-
key: ${{ runner.os }}-sonar
28-
restore-keys: ${{ runner.os }}-sonar
29-
- name: Cache Maven packages
30-
uses: actions/cache@v5
31-
with:
32-
path: ~/.m2
33-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
34-
restore-keys: ${{ runner.os }}-m2
35-
- name: Build and analyze
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
38-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Raouf25_Spring-Boot-efficient-search-API
12+
uses: ./.github/workflows/reusable-build.yml
13+
secrets: inherit
4014

4115
docker:
4216
# docker-repository: https://hub.docker.com/r/raouf25/spring-boot-efficient-search-api

.github/workflows/dependabot-reviewer.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,8 @@ env:
1212

1313
jobs:
1414
build:
15-
name: Build and analyze
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v6
19-
with:
20-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21-
- name: Set up JDK 24
22-
uses: actions/setup-java@v5
23-
with:
24-
distribution: 'temurin' # See 'Supported distributions' for available options
25-
java-version: '24'
26-
- name: Cache SonarCloud packages
27-
uses: actions/cache@v5
28-
with:
29-
path: ~/.sonar/cache
30-
key: ${{ runner.os }}-sonar
31-
restore-keys: ${{ runner.os }}-sonar
32-
- name: Cache Maven packages
33-
uses: actions/cache@v5
34-
with:
35-
path: ~/.m2
36-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
37-
restore-keys: ${{ runner.os }}-m2
38-
- name: Build and analyze
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
41-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
42-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Raouf25_Spring-Boot-efficient-search-API
15+
uses: ./.github/workflows/reusable-build.yml
16+
secrets: inherit
4317

4418

4519
review-dependabot-pr:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Reusable Build and Analyze
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
name: Build and analyze
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v6
12+
with:
13+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
14+
- name: Set up JDK 24
15+
uses: actions/setup-java@v5
16+
with:
17+
distribution: 'temurin' # See 'Supported distributions' for available options
18+
java-version: '24'
19+
- name: Cache SonarCloud packages
20+
uses: actions/cache@v4
21+
with:
22+
path: ~/.sonar/cache
23+
key: ${{ runner.os }}-sonar
24+
restore-keys: ${{ runner.os }}-sonar
25+
- name: Cache Maven packages
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.m2
29+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
30+
restore-keys: ${{ runner.os }}-m2
31+
- name: Build and analyze
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
34+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
35+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Raouf25_Spring-Boot-efficient-search-API
36+

0 commit comments

Comments
 (0)