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