Added git status for debug #24
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
# This is a basic workflow to help you get started with Actions | |
name: TRIVY-SCAN | |
# Controls when the action will run. | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
image-ref: | |
description: Full docker image path (e.g. docker.io/hkube/site:v1.2.3) | |
required: true | |
default: 'docker.io/hkube/site:v2.6.4' | |
jobs: | |
# This workflow contains a single job called "scan_and_upload" | |
scan_and_upload: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Trivy | |
run: | | |
wget https://github.com/aquasecurity/trivy/releases/download/v0.43.0/trivy_0.43.0_Linux-64bit.deb | |
sudo dpkg -i trivy_0.43.0_Linux-64bit.deb | |
- name: Run Trivy license scan on repo | |
run: trivy fs /home/runner/work --scanners license --license-full --severity 'HIGH,CRITICAL' --format json --output trivy_license_filesystem.json | |
- name: Run Trivy vulnerability scanner on repo | |
run: trivy fs /home/runner/work --severity 'HIGH,CRITICAL' --format json --output trivy_vuln_filesystem.json | |
- name: Update a branch with scan results | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
existed_in_remote=$(git ls-remote --heads origin trivy-scan-results) | |
if [[ ${existed_in_remote} ]]; then | |
echo "branch exists in remote" | |
git fetch origin trivy-scan-results | |
echo "branch fetched" | |
git checkout trivy-scan-results | |
echo "origin branch swapped" | |
else | |
git checkout -b trivy-scan-results | |
echo "new branch swapped" | |
fi | |
mkdir -p TrivyScans | |
cp trivy_license_filesystem.json TrivyScans/ | |
cp trivy_vuln_filesystem.json TrivyScans/ | |
git add TrivyScans/trivy_license_filesystem.json | |
git add TrivyScans/trivy_vuln_filesystem.json | |
git status | |
git commit -m "Add trivy scan result files to the folder 'TrivyScans'" | |
git push origin trivy-scan-results | |
- name: Display scan result branch link | |
run: echo "Results uploaded to [trivy-scan-results branch](https://github.com/$GITHUB_REPOSITORY/tree/trivy-scan-results/TrivyScans/)" | |
if: always() | |