Skip to content

Commit

Permalink
🔧 (#127): Add new pipeline for sbom generation for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Klaus committed Nov 2, 2024
1 parent d2b8abe commit a81799e
Show file tree
Hide file tree
Showing 6 changed files with 6,755 additions and 2,648 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/dependency-track-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
- name: mvn makeAggregateBom
run: mvn org.cyclonedx:cyclonedx-maven-plugin:2.8.0:makeBom --file backend/pom.xml

- uses: avides/actions-project-version-check@latest
- name: Get current project version
uses: avides/actions-project-version-check@latest
id: project_version
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/frontend-dependency-track.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Dependency Track for frontend

on:
push:
paths:
- frontend/**
- .github/workflows/frontend-dependency-track.yaml
branches: [ "**" ]
tags:
- 'spa-*.*.*'
pull_request:
paths:
- frontend/**
- .github/workflows/frontend-dependency-track.yaml
branches:
- main

jobs:
build:
if: ${{ !startsWith(github.ref, 'refs/heads/dependabot/maven/backend') }}
runs-on: ubuntu-latest

strategy:
matrix:
baseDirectory: [ "frontend/spa" ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install PNPM
run: npm install -g pnpm

- name: Install dependencies
run: pnpm install
working-directory: ${{ matrix.baseDirectory }}

- name: Create sBom
run: pnpm sbom
working-directory: ${{ matrix.baseDirectory }}

- name: Get current project version
uses: avides/actions-project-version-check@latest
id: project_version
with:
token: ${{ secrets.GITHUB_TOKEN }}
file-to-check: "${{ matrix.baseDirectory }}/package.json"

# Upload the SBOM to Dependency-Track
- name: Upload BOM to Dependency-Track
uses: DependencyTrack/[email protected]
with:
apiKey: ${{ secrets.DEPENDENCYTRACK_APIKEY }}
serverHostname: "dtrack.hopps.cloud"
bomFilename: "${{ matrix.baseDirectory }}/bom.json"
projectName: "${{ matrix.baseDirectory }}"
projectVersion: "${{ steps.project_version.outputs.version }}"
autoCreate: true
19 changes: 12 additions & 7 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
baseDirectory: [ "frontend/spa" ]

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -32,21 +37,21 @@ jobs:

- name: Install dependencies
run: pnpm install
working-directory: frontend/spa
working-directory: ${{ matrix.baseDirectory }}

- name: Run tests
run: pnpm run validate
working-directory: frontend/spa
working-directory: ${{ matrix.baseDirectory }}

- name: Build project
run: pnpm run build && ls -la
working-directory: frontend/spa
run: pnpm run build
working-directory: ${{ matrix.baseDirectory }}

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: frontend/spa/dist/
path: ${{ matrix.baseDirectory }}/dist/

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -71,7 +76,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: frontend/spa
file: frontend/spa/docker/Dockerfile
context: ${{ matrix.baseDirectory }}
file: ${{ matrix.baseDirectory }}/docker/Dockerfile
push: ${{ !startsWith(github.ref, 'refs/heads/dependabot/maven/backend') }}
tags: ghcr.io/${{ github.repository }}/frontend:${{ env.VERSION }}
2 changes: 2 additions & 0 deletions frontend/spa/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ coverage/*
*.sw?
/tsconfig.app.tsbuildinfo
/tsconfig.node.tsbuildinfo

bom.json
6 changes: 4 additions & 2 deletions frontend/spa/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hopps-spa",
"private": true,
"version": "0.0.1",
"version": "0.0.1-alpha",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -12,7 +12,8 @@
"validate": "pnpm run lint && pnpm run test",
"test": "vitest run",
"test:dev": "vitest",
"test:coverage": "vitest run --coverage"
"test:coverage": "vitest run --coverage",
"sbom": "cdxgen -o bom.json"
},
"dependencies": {
"@radix-ui/react-icons": "^1.3.0",
Expand All @@ -35,6 +36,7 @@
"vite-plugin-svgr": "^4.2.0"
},
"devDependencies": {
"@cyclonedx/cdxgen": "^10.11.0",
"@eslint/js": "^9.11.1",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/react": "^16.0.1",
Expand Down
Loading

0 comments on commit a81799e

Please sign in to comment.