Skip to content

patch: Swap Trivy for Grype in CI pipeline #409

patch: Swap Trivy for Grype in CI pipeline

patch: Swap Trivy for Grype in CI pipeline #409

Workflow file for this run

name: CI Pipeline
permissions:
contents: read
pull-requests: write
checks: write
actions: read
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
grype_version:
description: "Grype version to install"
default: "v0.110.0"
type: string
grype_commit_sha:
description: "Grype commit SHA for install script"
default: "dee8de483dfba5b4e0bc0aa8e4ab2ce52137e490"
type: string
jobs:
build-verification:
name: Build Verification
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.3
terraform_wrapper: false
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.24.0
- name: Terraform Validate
run: |
terraform init -backend=false
terraform validate
working-directory: infrastructure
- name: Run Integration Tests
run: |
terraform init -backend=false
terraform test
working-directory: tests/integration-tests
- name: Run End to End Tests
run: |
go mod tidy
go test -v -timeout 60m
working-directory: tests/end-to-end-tests
env:
GOMAXPROCS: 8
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
TF_STATE_RESOURCE_GROUP: ${{ secrets.TF_STATE_RESOURCE_GROUP }}
TF_STATE_STORAGE_ACCOUNT: ${{ secrets.TF_STATE_STORAGE_ACCOUNT }}
TF_STATE_STORAGE_CONTAINER: ${{ secrets.TF_STATE_STORAGE_CONTAINER }}
static-code-analysis:
name: Static Code Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.9.3
- name: Run Terraform Format
run: terraform fmt -check
working-directory: infrastructure
- name: Run Terraform Lint
uses: terraform-linters/setup-tflint@v1
with:
tflint_version: latest
- run: tflint
- name: Install Checkov
run: sudo apt-get update && sudo apt-get install -y python3-pip && pip3 install checkov
- name: Run Checkov Scan
run: checkov --directory infrastructure --skip-path example --list
- name: Install GitLeaks
run: |
curl -sSL https://github.com/zricethezav/gitleaks/releases/download/v8.2.4/gitleaks_8.2.4_linux_x64.tar.gz | tar -xz
sudo mv gitleaks /usr/local/bin/
- name: Run GitLeaks Scan
run: gitleaks detect --source . --config .gitleaks.toml
- name: Install Grype
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/grype/${{ inputs.grype_commit_sha || 'dee8de483dfba5b4e0bc0aa8e4ab2ce52137e490' }}/install.sh | bash -s -- -b /usr/local/bin ${{ inputs.grype_version || 'v0.110.0' }}
- name: Run Grype Filesystem Scan
run: grype "dir:./" --fail-on high
publishing:
name: Publish Release
runs-on: ubuntu-latest
needs: [build-verification, static-code-analysis]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false # Disable default GITHUB_TOKEN persistence
- name: Create Semantic Release
uses: cycjimmy/semantic-release-action@v4.1.0
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Output Release Details
if: steps.semantic-release.outputs.new_release_published == 'true'
run: |
echo ${{ steps.semantic-release.outputs.new_release_version }}
echo ${{ steps.semantic-release.outputs.new_release_major_version }}
echo ${{ steps.semantic-release.outputs.new_release_minor_version }}
echo ${{ steps.semantic-release.outputs.new_release_patch_version }}