-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SC-15838: Scheduled job for image vulnerabilities detection
- Loading branch information
1 parent
3e4a94f
commit ce85084
Showing
1 changed file
with
41 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
name: Vulnerability detection | ||
|
||
on: | ||
schedule: | ||
- cron: '0 9 * * *' | ||
push: | ||
branches-ignore: | ||
- master | ||
|
@@ -74,6 +76,45 @@ jobs: | |
- run: | | ||
echo "${{ steps.docker-scan.outputs.total }} total vulnerabilities." | ||
- name: Set Date and Time | ||
id: set-date | ||
run: echo "::set-output name=current_datetime::$(date +'%Y-%m-%d %H:%M:%S')" | ||
|
||
- name: Set Color | ||
id: set-color | ||
run: | | ||
if [[ "${{ true }}" ]]; then | ||
COLOR="#008000" | ||
else | ||
COLOR="#ff0000" | ||
fi | ||
echo "::set-output name=color::$COLOR" | ||
- name: Send GitHub Action trigger data to Slack workflow | ||
id: slack | ||
uses: slackapi/[email protected] | ||
with: | ||
payload: | | ||
{ | ||
"text": "Scanned image tag *${{ matrix.tags }}*.", | ||
"attachments": [ | ||
{ | ||
"pretext": "Vulnerability scan outputs for ${{ steps.set-date.outputs.current_datetime }}", | ||
"color": "${{ steps.set-color.outputs.color }}", | ||
"fields": [ | ||
{ | ||
"title": "Status", | ||
"short": true, | ||
"value": "*${{ steps.docker-scan.outputs.total }}* total vulnerabilities" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | ||
|
||
- name: Fail the execution | ||
if: ${{ steps.docker-scan.outputs.total > 0 }} | ||
run: exit 1 |