Skip to content

Commit

Permalink
SC-15838: Scheduled job for image vulnerabilities detection (#81)
Browse files Browse the repository at this point in the history
* SC-15838: Scheduled job for image vulnerabilities detection

* Update security.yml
  • Loading branch information
alexanderM91 authored Oct 12, 2023
1 parent 3e4a94f commit f9f1f5e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/security.yml
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
Expand Down Expand Up @@ -74,6 +76,48 @@ jobs:
- run: |
echo "${{ steps.docker-scan.outputs.total }} total vulnerabilities."
- name: Set Date and Time
id: set-date
if: github.event.schedule == '0 9 * * *'
run: echo "::set-output name=current_datetime::$(date +'%Y-%m-%d %H:%M:%S')"

- name: Set Color
id: set-color
if: github.event.schedule == '0 9 * * *'
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
if: github.event.schedule == '0 9 * * *'
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

0 comments on commit f9f1f5e

Please sign in to comment.