Simplify Github actions

Consolidate build steps to 1 script this way we don't run multiple builds for pushing a branch and create a PR.
This commit is contained in:
Nanne Baars 2021-10-23 21:12:28 +02:00 committed by Nanne Baars
parent eb163c8df1
commit 01d3453c41
3 changed files with 9 additions and 59 deletions

View File

@ -1,52 +0,0 @@
name: "Branch build"
on:
push:
branches-ignore:
- master
- develop
- release/*
jobs:
install-notest:
runs-on: ubuntu-latest
name: "Package and linting"
steps:
- uses: actions/checkout@v2
- name: set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 16
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v2.1.5
with:
path: ~/.m2
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ubuntu-latest-m2
- name: Test with Maven
run: mvn install -DskipTests
testing:
needs: install-notest
runs-on: ubuntu-latest
strategy:
matrix:
args:
- mvn -pl '!webgoat-integration-tests' test
- mvn -pl webgoat-integration-tests test
steps:
- uses: actions/checkout@v2
- name: set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 16
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v2.1.5
with:
path: ~/.m2
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ubuntu-latest-m2
- name: Test with Maven
run: ${{ matrix.args }}

View File

@ -1,4 +1,4 @@
name: "Pull request build" name: "Build"
on: on:
pull_request: pull_request:
paths-ignore: paths-ignore:
@ -8,10 +8,6 @@ on:
- 'LICENSE' - 'LICENSE'
- 'docs/**' - 'docs/**'
push: push:
branches:
- master
- develop
- release/*
tags-ignore: tags-ignore:
- '*' - '*'
paths-ignore: paths-ignore:
@ -23,6 +19,12 @@ on:
jobs: jobs:
build: build:
if: |
${{
github.event_name == 'pull_request' ||
(github.event_name == 'push' &&
github.event.pull_request.head.repo.full_name != github.repository)
}}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
@ -43,4 +45,4 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2 restore-keys: ${{ runner.os }}-m2
- name: Build with Maven - name: Build with Maven
run: mvn clean install run: mvn package

View File

@ -39,7 +39,7 @@ jobs:
- name: Build with Maven - name: Build with Maven
run: | run: |
mvn versions:set -DnewVersion=${{ env.WEBGOAT_MAVEN_VERSION }} mvn versions:set -DnewVersion=${{ env.WEBGOAT_MAVEN_VERSION }}
mvn clean install -DskipTests mvn install -DskipTests
- name: "Create release" - name: "Create release"
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1