Skip to content

Commit 3029bdc

Browse files
committed
Reusable CodeQL and Scorecards analysis
1 parent 89f54ff commit 3029bdc

File tree

2 files changed

+11
-83
lines changed

2 files changed

+11
-83
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
# limitations under the License.
1616
#
1717

18-
name: "CodeQL"
18+
name: codeql-analysis
1919

2020
on:
2121
push:
22-
branches: [ 2.x ]
22+
branches: [ "2.x", "main" ]
2323
pull_request:
24-
# The branches below must be a subset of the branches provided in `on.push.branches`
25-
branches: [ 2.x ]
24+
branches: [ "2.x", "main" ]
2625
schedule:
2726
- cron: '32 12 * * 5'
2827

@@ -31,51 +30,13 @@ permissions: read-all
3130
jobs:
3231

3332
analyze:
34-
name: Analyze
35-
runs-on: ubuntu-latest
33+
uses: apache/logging-parent/.github/workflows/codeql-analysis-reusable.yaml@main
34+
with:
35+
java-version: |
36+
11
37+
8
38+
# Permissions required to publish Security Alerts
3639
permissions:
3740
actions: read
3841
contents: read
3942
security-events: write
40-
41-
strategy:
42-
fail-fast: false
43-
matrix:
44-
language: [ 'java' ]
45-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
46-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
47-
48-
steps:
49-
50-
- name: Checkout repository
51-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
52-
53-
# Initializes the CodeQL tools for scanning.
54-
- name: Initialize CodeQL
55-
uses: github/codeql-action/init@2cb752a87e96af96708ab57187ab6372ee1973ab # 2.22.0
56-
with:
57-
languages: ${{ matrix.language }}
58-
# If you wish to specify custom queries, you can do so here or in a config file.
59-
# By default, queries listed here will override any specified in a config file.
60-
# Prefix the list here with "+" to use these queries and those in the config file.
61-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
62-
63-
# JDK 11 is used for the build.
64-
- name: Setup JDK
65-
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # 3.13.0
66-
with:
67-
distribution: temurin
68-
java-version: 11
69-
cache: maven
70-
71-
- name: Build with Maven
72-
timeout-minutes: 60
73-
shell: bash
74-
run: |
75-
./mvnw \
76-
--show-version --batch-mode --errors --no-transfer-progress \
77-
-DskipTests -P!java8-tests \
78-
clean verify
79-
80-
- name: Perform CodeQL Analysis
81-
uses: github/codeql-action/analyze@2cb752a87e96af96708ab57187ab6372ee1973ab # 2.22.0

.github/workflows/scorecards-analysis.yml

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
name: Scorecards
18+
name: scorecards-analysis
1919

2020
on:
2121
branch_protection_rule:
@@ -29,43 +29,10 @@ permissions: read-all
2929
jobs:
3030

3131
analysis:
32-
33-
name: "Scorecards analysis"
34-
runs-on: ubuntu-latest
32+
uses: apache/logging-parent/.github/workflows/scorecards-analysis-reusable.yaml@main
3533
permissions:
3634
# Needed to upload the results to the code-scanning dashboard.
3735
security-events: write
3836
actions: read
3937
id-token: write # This is required for requesting the JWT
4038
contents: read # This is required for actions/checkout
41-
42-
steps:
43-
44-
- name: "Checkout code"
45-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0
46-
with:
47-
persist-credentials: false
48-
49-
- name: "Run analysis"
50-
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # 2.2.0
51-
with:
52-
results_file: results.sarif
53-
results_format: sarif
54-
# A read-only PAT token, which is sufficient for the action to function.
55-
# The relevant discussion: https://github.com/ossf/scorecard-action/issues/188
56-
repo_token: ${{ secrets.GITHUB_TOKEN }}
57-
# Publish the results for public repositories to enable scorecard badges.
58-
# For more details: https://github.com/ossf/scorecard-action#publishing-results
59-
publish_results: true
60-
61-
- name: "Upload artifact"
62-
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # 3.1.0
63-
with:
64-
name: SARIF file
65-
path: results.sarif
66-
retention-days: 5
67-
68-
- name: "Upload to code-scanning"
69-
uses: github/codeql-action/upload-sarif@2cb752a87e96af96708ab57187ab6372ee1973ab # 2.1.22
70-
with:
71-
sarif_file: results.sarif

0 commit comments

Comments
 (0)