From 4c95c9ec6ac4fa2f18c51d6a3e2f3767553bc2ee Mon Sep 17 00:00:00 2001 From: Nanne Baars Date: Thu, 16 Feb 2023 21:40:34 +0100 Subject: [PATCH] ci: add step to build and verify Docker image --- .github/workflows/build.yml | 120 +++++++++++++++++------------------- 1 file changed, 57 insertions(+), 63 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e652ee69..8fdb8cfbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,66 +1,60 @@ -name: "Build" +name: "Pull requests build" on: - pull_request: - paths-ignore: - - '.txt' - - 'LICENSE' - - 'docs/**' - push: - branches: - - main - tags-ignore: - - '*' - paths-ignore: - - '.txt' - - 'LICENSE' - - 'docs/**' + pull_request: + paths-ignore: + - '.txt' + - 'LICENSE' + - 'docs/**' jobs: - pr-build: - if: > - github.event_name == 'pull_request' && !github.event.pull_request.draft && ( - github.event.action == 'opened' || - github.event.action == 'reopened' || - github.event.action == 'synchronize' - ) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - architecture: x64 - - name: Cache Maven packages - uses: actions/cache@v3.2.5 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - 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 - with: - distribution: 'temurin' - java-version: 17 - architecture: x64 - - name: Cache Maven packages - uses: actions/cache@v3.2.5 - 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 + pr-build: + if: > + github.event_name == 'pull_request' && !github.event.pull_request.draft && ( + github.event.action == 'opened' || + github.event.action == 'reopened' || + github.event.action == 'synchronize' + ) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + architecture: x64 + - name: Cache Maven packages + uses: actions/cache@v3.2.5 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2- + - name: Build with Maven + run: mvn --no-transfer-progress verify + - 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: + 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: + context: ./ + file: ./Dockerfile_desktop + push: false + build-args: | + webgoat_version=${{ env.WEBGOAT_MAVEN_VERSION }}