From 332ef45c4afffe2ea68fa2cee4a33a703cc252f9 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 20 Jun 2024 22:46:07 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=9B=B4=E6=96=B0=20GitHub=20Action=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 28 +++++++++++++++++++ .github/workflows/{deploy.yml => scan.yml} | 32 ++++++++++++++-------- 2 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{deploy.yml => scan.yml} (52%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..9022fb41 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: Build + +on: + pull_request: + branches: + - dev + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + jdk-version: + - 17 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: "adopt" + java-version: ${{ matrix.jdk-version }} + cache: "maven" + - name: Compile + run: | + sed -i.bak '//,/<\/repositories>/d' pom.xml + sed -i.bak '//,/<\/pluginRepositories>/d' pom.xml + mvn -B compile --file pom.xml diff --git a/.github/workflows/deploy.yml b/.github/workflows/scan.yml similarity index 52% rename from .github/workflows/deploy.yml rename to .github/workflows/scan.yml index 48a16899..9f5a1d82 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/scan.yml @@ -1,26 +1,31 @@ -name: Analysis Code Quality +name: Scan on: - # 推送时执行 push: - branches: [dev] - # 可手动执行 - workflow_dispatch: + branches: + - dev + pull_request: + branches: + - dev jobs: - # Sonar 扫描 sonar-scan: runs-on: ubuntu-latest + strategy: + matrix: + jdk-version: + - 17 steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@master + uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 17 + distribution: "adopt" + java-version: ${{ matrix.jdk-version }} + cache: "maven" - name: Cache SonarCloud packages uses: actions/cache@v3 with: @@ -34,7 +39,10 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Analyze - run: mvn -B verify -Psonar + run: | + sed -i.bak '//,/<\/repositories>/d' pom.xml + sed -i.bak '//,/<\/pluginRepositories>/d' pom.xml + mvn -B verify -Psonar env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}