Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 5b117cd

Browse files
committed
👷 Add reusable build and dependabot specific workflow
1 parent efd953f commit 5b117cd

File tree

3 files changed

+75
-31
lines changed

3 files changed

+75
-31
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Build
2+
3+
on:
4+
pull_request_target
5+
6+
jobs:
7+
build:
8+
name: Build
9+
if: ${{ github.actor == 'dependabot[bot]' }}
10+
uses: fonimus/ssh-shell-spring-boot/.github/workflows/reusable-build.yml@master
11+
with:
12+
sonar_analysis: false

‎.github/workflows/build.yml

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,9 @@ on:
1010

1111
jobs:
1212
build:
13-
14-
name: Build and analyze
15-
16-
runs-on: ubuntu-latest
17-
18-
steps:
19-
- uses: actions/checkout@v2
20-
- name: Set up JDK 11
21-
uses: actions/setup-java@v1
22-
with:
23-
java-version: 11
24-
25-
- name: Cache maven repository
26-
uses: actions/cache@v2
27-
with:
28-
path: ~/.m2/repository
29-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
30-
restore-keys: ${{ runner.os }}-maven-
31-
32-
- name: Cache sonar packages
33-
uses: actions/cache@v1
34-
with:
35-
path: ~/.sonar/cache
36-
key: ${{ runner.os }}-sonar
37-
restore-keys: ${{ runner.os }}-sonar
38-
39-
- name: Build and analyze
40-
run: mvn -B -ntp verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
41-
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
13+
name: Build
14+
if: ${{ github.actor != 'dependabot[bot]' }}
15+
uses: fonimus/ssh-shell-spring-boot/.github/workflows/reusable-build.yml@master
16+
secrets:
17+
sonar_token: ${{ secrets.SONAR_TOKEN }}
18+
github_token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Reusable Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
sonar_analysis:
7+
required: false
8+
type: boolean
9+
default: true
10+
description: Whether to make sonar analysis (sonar_token and github_token become mandatory)
11+
secrets:
12+
sonar_token:
13+
required: false
14+
github_token:
15+
required: false
16+
17+
jobs:
18+
build:
19+
20+
name: Build and analyze
21+
runs-on: ubuntu-latest
22+
if: ${{ github.actor != 'dependabot[bot]' }}
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Set up JDK 11
27+
uses: actions/setup-java@v1
28+
with:
29+
java-version: 11
30+
31+
- name: Cache maven repository
32+
uses: actions/cache@v2
33+
with:
34+
path: ~/.m2/repository
35+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
36+
restore-keys: ${{ runner.os }}-maven
37+
38+
- name: Build
39+
run: mvn -B -ntp verify
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43+
44+
- name: Cache sonar packages
45+
if: ${{ inputs.sonar_analysis == true }}
46+
uses: actions/cache@v1
47+
with:
48+
path: ~/.sonar/cache
49+
key: ${{ runner.os }}-sonar
50+
restore-keys: ${{ runner.os }}-sonar
51+
52+
- name: Analyze
53+
if: ${{ inputs.sonar_analysis == true }}
54+
run: mvn -B -ntp org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.github_token }}
57+
SONAR_TOKEN: ${{ secrets.sonar_token }}

0 commit comments

Comments
 (0)