-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7438 from ayeshLK/connector-trivy-workflow
Add new workflow for connector trivy-scan
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Trivy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
additional-build-flags: | ||
required: false | ||
type: string | ||
default: "" | ||
|
||
jobs: | ||
ubuntu-build: | ||
name: Build on Ubuntu | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'ballerina-platform' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get Ballerina Version | ||
run: | | ||
BAL_VERSION=$(grep -w 'ballerinaLangVersion' gradle.properties | cut -d= -f2 | rev | cut --complement -d- -f1 | rev) | ||
if [ -z "$BAL_VERSION" ]; then | ||
BAL_VERSION="latest" | ||
fi | ||
echo "BAL_VERSION=$BAL_VERSION" >> $GITHUB_ENV | ||
echo "Ballerina Version: $BAL_VERSION" | ||
- name: Set Up Ballerina | ||
uses: ballerina-platform/setup-ballerina@v1.1.3 | ||
with: | ||
version: ${{ env.BAL_VERSION }} | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: "temurin" | ||
java-version: 17.0.7 | ||
|
||
- name: Build with Gradle | ||
env: | ||
packageUser: ${{ github.actor }} | ||
packagePAT: ${{ secrets.GITHUB_TOKEN }} | ||
run: ./gradlew build -x test ${{ inputs.additional-build-flags }} | ||
|
||
- name: Create lib directory if not exists | ||
run: mkdir -p ballerina/lib | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@master | ||
env: | ||
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db | ||
TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db | ||
with: | ||
scan-type: "rootfs" | ||
scan-ref: "${{ github.workspace }}/ballerina/lib" | ||
format: "table" | ||
timeout: "10m0s" | ||
exit-code: "1" | ||
scanners: "vuln" | ||
cache-dir: "/tmp/trivy-cache" |