-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (95 loc) · 3.18 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: ci
on:
push:
branches: [ ]
pull_request:
branches: [ ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
# 设置 Maven Settings
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v21
with:
profiles: >
[
{
"id": "ci",
"properties": {
"altSnapshotDeploymentRepository": "${{ secrets.ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY }}",
"altReleaseDeploymentRepository": "${{ secrets.ALT_RELEASE_DEPLOYMENT_REPOSITORY }}"
}
}
]
servers: >
[
{
"id": "ossrh",
"username": "${{ secrets.MVN_SERVER_USER }}",
"password": "${{ secrets.MVN_SERVER_PASSWORD }}"
}
]
repositories: >
[
{
"id": "ossrh-releases",
"name": "ossrh releases",
"url": "https://s01.oss.sonatype.org/content/repositories/releases/",
"releases": {
"enabled": "true",
"updatePolicy": "always"
},
"snapshots": {
"enabled": "false",
"updatePolicy": "always"
}
},
{
"id": "ossrh-snapshots",
"name": "ossrh snapshots",
"url": "https://s01.oss.sonatype.org/content/repositories/snapshots/",
"releases": {
"enabled": "false",
"updatePolicy": "always"
},
"snapshots": {
"enabled": "true",
"updatePolicy": "always"
}
}
]
- name: Clean Maven Repository
run: rm -rf /home/runner/.m2/repository
- name: Cat Setting.xml
run: cat /home/runner/.m2/settings.xml
- name: Build with Maven
run: mvn -U -B package -Pgithub,ci --file pom.xml
- name: Deploy with Maven
run: mvn -B deploy -Pgithub,ci --file pom.xml
- name: Codecov
uses: codecov/codecov-action@v3
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify -Pci org.sonarsource.scanner.maven:sonar-maven-plugin:sonar