add wiz scan to the pipeline (SWG-14342) #257
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR build - master | |
on: | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ 11 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn -B -U verify --file pom.xml | |
build-java8: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ 8 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: ${{ matrix.java }} | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn -B -U clean verify -DskipTests -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true -Psamples-java8 --file pom.xml | |
scan-with-wiz: | |
name: Trigger Wiz Scanning | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
if: success() | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_SB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }} | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
run: | | |
docker buildx build --load -t swaggerhub/swagger-codegen:latest . | |
- name: Download Wiz CLI | |
run: curl -o wizcli https://downloads.wiz.io/wizcli/latest/wizcli-linux-amd64 && chmod +x wizcli | |
- name: Authenticate to Wiz | |
run: ./wizcli auth --id "$WIZ_CLIENT_ID" --secret "$WIZ_CLIENT_SECRET" | |
env: | |
WIZ_CLIENT_ID: ${{ secrets.WIZ_CLIENT_ID }} | |
WIZ_CLIENT_SECRET: ${{ secrets.WIZ_CLIENT_SECRET }} | |
- name: Run wiz-cli docker image scan | |
run: | | |
./wizcli docker scan --image $TAG --policy "$POLICY" > | |
./wizcli docker tag --image $TAG > | |
env: | |
TAG: swaggerhub/swagger-codegen:latest | |
POLICY: "SmartBear default vulnerabilities policy" |