-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
207d892
commit e3cc4e5
Showing
2 changed files
with
50 additions
and
27 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,28 +1,40 @@ | ||
name: Scan with trivy | ||
name: Scan the target image with trivy | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
- cron: '0 0 * * *' | ||
jobs: | ||
scan: | ||
name: Scan via trivy | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE: goodwithtech/dockle | ||
# "*v0.2*" pattern | ||
FILTER: v0.2 | ||
IMAGE: goodwithtech/dockle # target image name | ||
FILTER: v0.2 # pattern : /*v0.2*/ | ||
steps: | ||
- name: Fetch last tag | ||
id: versions | ||
- name: detect a target image tag | ||
id: target | ||
run: echo ::set-output name=ver::$( | ||
docker run --rm goodwithtech/dockertags -contain $FILTER -limit 1 -format json $IMAGE | ||
| jq -r .[0].tags[0] | ||
) | ||
- name: detect a trivy image tag | ||
id: trivy | ||
run: echo ::set-output name=ver::$( | ||
docker run --rm goodwithtech/dockertags -limit 1 -format json aquasec/trivy | ||
| jq -r .[0].tags[0] | ||
) | ||
- name: check tags | ||
run: | | ||
echo ::set-output name=trivy::$(docker run --rm goodwithtech/dockertags -limit 1 -format json aquasec/trivy | jq -r .[0].tags[0]) | ||
echo ::set-output name=target::$(docker run --rm goodwithtech/dockertags -contain $FILTER -limit 1 -format json $IMAGE | jq -r .[0].tags[0]) | ||
- name: Scan image for vulnerabilities | ||
run: docker run aquasec/trivy:${{ steps.versions.outputs.trivy }} --exit-code 1 --no-progress $IMAGE:${{ steps.versions.outputs.target }} | ||
- name: Slack Notification | ||
echo trivy ${{ steps.trivy.outputs.ver }} | ||
echo $IMAGE ${{ steps.target.outputs.ver }} | ||
- name: scan the image with trivy | ||
run: docker run aquasec/trivy:${{ steps.trivy.outputs.ver }} | ||
--cache-dir /var/lib/trivy --exit-code 1 --no-progress | ||
$IMAGE:${{ steps.target.outputs.ver }} | ||
- name: notify to slack | ||
if: failure() | ||
uses: rtCamp/action-slack-notify@master | ||
env: | ||
SLACK_CHANNEL: channel # set target channel name | ||
SLACK_CHANNEL: channel # target channel | ||
SLACK_MESSAGE: 'failed : trivy detects vulnerabilities' | ||
SLACK_TITLE: trivy-scan-notifier | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
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