Skip to content

Merge pull request #374 from kube-HPC/update-version-node-22 #216

Merge pull request #374 from kube-HPC/update-version-node-22

Merge pull request #374 from kube-HPC/update-version-node-22 #216

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI-MAIN
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
# 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:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN }}
- run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- uses: actions/setup-node@v1
with:
node-version: 22.x
- run: npm ci
- run: NODE_ENV=test npm run-script test-travis
- name: version
run: |
git checkout -f -b version-branch
npm version patch -m "$(git log -1 --pretty=%B) .... bump version [skip ci]"
git push origin version-branch:master --follow-tags
- name: build
run: |
docker login --username yehiyam --password ${DOCKER_HUB_PASS}
PRIVATE_REGISTRY=docker.io/hkube npm run build
export IMAGE_NAME=$(PRIVATE_REGISTRY=docker.io/hkube npm run build | tail -1 | awk '{print $NF}')
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
echo "IMAGE_NAME: $IMAGE_NAME"
env:
DOCKER_HUB_PASS: ${{ secrets.DOCKER_PASSWORD }}
- 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' > trivy_license_filesystem.txt
- name: Run Trivy vulnerability scanner on repo
run: trivy fs /home/runner/work --severity 'HIGH,CRITICAL' --format sarif --output trivy_vuln_filesystem.sarif
- name: Run Trivy license scan on image
run: trivy image --scanners license --license-full --severity 'HIGH,CRITICAL' '${{ env.IMAGE_NAME }}' > trivy_license_image.txt
- name: Run Trivy vulnerability scanner on image
run: trivy image --severity 'HIGH,CRITICAL' --format sarif --output trivy_vuln_image.sarif '${{ env.IMAGE_NAME }}'
- name: Upload Trivy image vulnerability results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy_vuln_image.sarif'
category: 'Trivy-Vulnerability-Image'
- name: Upload Trivy repo vulnerability results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy_vuln_filesystem.sarif'
category: 'Trivy-Vulnerability-Repo'
- name: Update a branch with scan results
run: |
git config --global user.email "action@github.com"
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
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
echo "$TIMESTAMP" > ScanTimeStamp.txt
cp ScanTimeStamp.txt TrivyScans/
cp trivy_license_filesystem.txt TrivyScans/
cp trivy_license_image.txt TrivyScans/
git add TrivyScans/trivy_license_filesystem.txt
git add TrivyScans/ScanTimeStamp.txt
git commit -m "Add trivy scan result files to the folder 'TrivyScans'"
git push origin trivy-scan-results
- name: Display branch and file path link
run: echo "Results uploaded to [trivy-scan-results branch](https://github.com/$GITHUB_REPOSITORY/tree/trivy-scan-results/TrivyScans/)"
- name: trigger
id: trigger
uses: octokit/request-action@v2.x
with:
route: POST /repos/kube-HPC/release-manager/dispatches
event_type: trigger
env:
GITHUB_TOKEN: '${{ secrets.GH_TOKEN }}'