ci: add step to build and verify Docker image

This commit is contained in:
Nanne Baars 2023-02-16 21:40:34 +01:00 committed by Nanne Baars
parent f6c7a54931
commit 4c95c9ec6a

View File

@ -1,19 +1,10 @@
name: "Build"
name: "Pull requests build"
on:
pull_request:
paths-ignore:
- '.txt'
- 'LICENSE'
- 'docs/**'
push:
branches:
- main
tags-ignore:
- '*'
paths-ignore:
- '.txt'
- 'LICENSE'
- 'docs/**'
jobs:
pr-build:
@ -43,24 +34,27 @@ jobs:
restore-keys: ${{ runner.os }}-m2-
- name: Build with Maven
run: mvn --no-transfer-progress verify
build:
if: github.repository == 'WebGoat/WebGoat' && github.event_name == 'push'
runs-on: ubuntu-latest
name: "Branch build"
steps:
- uses: actions/checkout@v3
- name: set up JDK 17
uses: actions/setup-java@v3
- name: "Set up QEMU"
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2.1.0
- name: "Set up Docker Buildx"
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v2
- name: "Verify Docker WebGoat build"
if: runner.os == 'Linux'
uses: docker/build-push-action@v4.0.0
with:
distribution: 'temurin'
java-version: 17
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v3.2.5
context: ./
file: ./Dockerfile
push: false
build-args: |
webgoat_version=${{ env.WEBGOAT_MAVEN_VERSION }}
- name: "Verify Docker WebGoat desktop build"
uses: docker/build-push-action@v4.0.0
if: runner.os == 'Linux'
with:
path: ~/.m2
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ubuntu-latest-m2-
- name: Test with Maven
run: mvn --no-transfer-progress verify
context: ./
file: ./Dockerfile_desktop
push: false
build-args: |
webgoat_version=${{ env.WEBGOAT_MAVEN_VERSION }}