-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Maven Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '8' | ||
distribution: 'adoptopenjdk' | ||
|
||
- name: Cache Maven dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/*.java') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Set up Maven settings | ||
run: | | ||
mkdir -p ~/.m2 | ||
echo '<settings><servers><server><id>github</id><username>${{ secrets.MY_GITHUB_USERNAME }}</username><password>${{ secrets.GITHUBPACKAGE_TOKEN }}</password></server></servers></settings>' > ~/.m2/settings.xml | ||
- name: Build and deploy to GitHub Packages | ||
run: | | ||
mvn clean deploy -DskipTests # 如果不需要跳过测试,删除 -DskipTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<settings> | ||
<servers> | ||
<server> | ||
<id>github</id> | ||
<username>YOUR_GITHUB_USERNAME</username> | ||
<password>${env.MY_GITHUB_TOKEN}</password> <!-- 使用 GitHub Actions 环境变量 --> | ||
</server> | ||
</servers> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
target/ | ||
.idea | ||
dependency-reduced-pom.xml | ||
dependency-reduced-pom.xml | ||
/.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters