Skip to content

Commit 696e0c0

Browse files
committed
add ci/cd
1 parent 7d96a08 commit 696e0c0

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

.github/codeql/codeql-config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "CodeQL Config"
2+
3+
queries:
4+
- uses: security-and-quality
5+
- uses: security-extended
6+
7+
paths:
8+
- src
9+
paths-ignore:
10+
- src/test
11+
- "**/*.test.java"
12+
- "**/*Test.java"
13+
14+
query-filters:
15+
- exclude:
16+
problem.severity:
17+
- warning
18+
- recommendation

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
ignore:
8+
- dependency-name: "org.springframework.boot"
9+
versions: ["3.x"]
10+
commit-message:
11+
prefix: "deps"
12+
include: "scope"
13+
labels:
14+
- "dependencies"
15+
- "security"
16+
open-pull-requests-limit: 10
17+
reviewers:
18+
- "your-github-username"
19+
20+
- package-ecosystem: "github-actions"
21+
directory: "/"
22+
schedule:
23+
interval: "weekly"
24+
commit-message:
25+
prefix: "ci"
26+
include: "scope"
27+
labels:
28+
- "ci-cd"
29+
- "dependencies"

.github/workflows/maven.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up JDK 8
17+
uses: actions/setup-java@v3
18+
with:
19+
java-version: "8"
20+
distribution: "temurin"
21+
cache: maven
22+
23+
- name: Cache Maven packages
24+
uses: actions/cache@v3
25+
with:
26+
path: ~/.m2
27+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
28+
restore-keys: ${{ runner.os }}-m2
29+
30+
- name: Build with Maven
31+
run: mvn -B package --file pom.xml
32+
33+
- name: Run Tests
34+
run: mvn test
35+
36+
- name: Run Security Check
37+
run: |
38+
chmod +x ./security-check.sh
39+
./security-check.sh
40+
41+
- name: Upload Test Results
42+
if: always()
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: test-results
46+
path: target/surefire-reports/
47+
48+
- name: Upload Security Reports
49+
if: always()
50+
uses: actions/upload-artifact@v3
51+
with:
52+
name: security-reports
53+
path: |
54+
target/dependency-check-report.html
55+
target/dependency-check-report.json
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Security Scan
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0" # 每周日运行
6+
workflow_dispatch: # 允许手动触发
7+
8+
jobs:
9+
security-scan:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set up JDK 8
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: "8"
18+
distribution: "temurin"
19+
cache: maven
20+
21+
- name: Initialize CodeQL
22+
uses: github/codeql-action/init@v2
23+
with:
24+
languages: java
25+
26+
- name: Build with Maven
27+
run: mvn -B package --file pom.xml
28+
29+
- name: Perform CodeQL Analysis
30+
uses: github/codeql-action/analyze@v2
31+
32+
- name: Run OWASP Dependency Check
33+
run: mvn org.owasp:dependency-check-maven:check
34+
35+
- name: Upload Security Reports
36+
if: always()
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: security-scan-reports
40+
path: |
41+
target/dependency-check-report.html
42+
target/dependency-check-report.json

0 commit comments

Comments
 (0)