-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
DevOps-Project-41 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oleitao
wants to merge
8
commits into
NotHarshhaa:master
Choose a base branch
from
oleitao:devops-project
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
67077dd
dotnet core app
oleitao 1256980
github
oleitao a15d52d
github workflow
oleitao 49d5b2c
README.md
oleitao 35b4cdb
end-to-end AI devsecops with gitops delivery flow
oleitao 382b6b0
fix
oleitao 4144428
revert fix
oleitao e2e0b5b
fix
oleitao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| name: "[P41] CI" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [devops-project, master] | ||
| paths: | ||
| - "DevOps-Project-41/app/**" | ||
| - ".github/workflows/project-41-ci.yml" | ||
| pull_request: | ||
| branches: [master] | ||
| paths: | ||
| - "DevOps-Project-41/app/**" | ||
| - ".github/workflows/project-41-ci.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| APP_DIR: DevOps-Project-41/app | ||
|
|
||
| jobs: | ||
| build-test: | ||
| name: Build & Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
oleitao marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: "8.0.x" | ||
|
|
||
| - name: Restore | ||
| working-directory: ${{ env.APP_DIR }} | ||
| run: dotnet restore | ||
|
|
||
| - name: Build | ||
| working-directory: ${{ env.APP_DIR }} | ||
| run: dotnet build -c Release --no-restore | ||
|
|
||
| - name: Test | ||
| working-directory: ${{ env.APP_DIR }} | ||
| run: dotnet test -c Release --no-build --logger trx --results-directory TestResults | ||
|
|
||
| - name: Upload test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: test-results | ||
| path: ${{ env.APP_DIR }}/TestResults | ||
|
|
||
| docker-build: | ||
| name: Docker Build (smoke test) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build API image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ env.APP_DIR }} | ||
| file: ${{ env.APP_DIR }}/Dockerfile | ||
| target: api | ||
| push: false | ||
| load: true | ||
| tags: ai-api:ci | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Build Worker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ env.APP_DIR }} | ||
| file: ${{ env.APP_DIR }}/Dockerfile | ||
| target: worker | ||
| push: false | ||
| load: true | ||
| tags: ai-worker:ci | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| name: "[P41] Release" | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "p41-v*.*.*" | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Image tag (e.g. 1.0.0)" | ||
| required: true | ||
| default: "1.0.0" | ||
|
|
||
|
oleitao marked this conversation as resolved.
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| id-token: write | ||
| security-events: write | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_OWNER: ${{ github.repository_owner }} | ||
| APP_DIR: DevOps-Project-41/app | ||
|
|
||
| jobs: | ||
| build-push-sign: | ||
| name: Build, Push and Sign | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| api-digest: ${{ steps.push-api.outputs.digest }} | ||
| worker-digest: ${{ steps.push-worker.outputs.digest }} | ||
| image-tag: ${{ steps.meta.outputs.version }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
oleitao marked this conversation as resolved.
oleitao marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Extract image metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: | | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=sha,prefix=sha- | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: "8.0.x" | ||
|
|
||
| - name: Run tests before release | ||
| working-directory: ${{ env.APP_DIR }} | ||
| run: dotnet test -c Release --logger trx | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Login to GHCR | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and push API image | ||
| id: push-api | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ env.APP_DIR }} | ||
| file: ${{ env.APP_DIR }}/Dockerfile | ||
| target: api | ||
| push: true | ||
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api:${{ steps.meta.outputs.version }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Build and push Worker image | ||
| id: push-worker | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ env.APP_DIR }} | ||
| file: ${{ env.APP_DIR }}/Dockerfile | ||
| target: worker | ||
| push: true | ||
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker:${{ steps.meta.outputs.version }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Install Cosign | ||
| uses: sigstore/cosign-installer@v3 | ||
|
|
||
| - name: Sign API image (keyless) | ||
| run: | | ||
| cosign sign --yes \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api@${{ steps.push-api.outputs.digest }} | ||
|
|
||
| - name: Sign Worker image (keyless) | ||
| run: | | ||
| cosign sign --yes \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker@${{ steps.push-worker.outputs.digest }} | ||
|
|
||
| - name: Generate SBOM for API (SPDX) | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api@${{ steps.push-api.outputs.digest }} | ||
| format: spdx-json | ||
| output: sbom-api.spdx.json | ||
|
|
||
| - name: Generate SBOM for API (CycloneDX) | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api@${{ steps.push-api.outputs.digest }} | ||
| format: cyclonedx | ||
| output: sbom-api.cyclonedx.json | ||
|
|
||
| - name: Generate SBOM for Worker (SPDX) | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker@${{ steps.push-worker.outputs.digest }} | ||
| format: spdx-json | ||
| output: sbom-worker.spdx.json | ||
|
|
||
| - name: Attest SBOM for API | ||
| run: | | ||
| cosign attest --yes \ | ||
| --predicate sbom-api.spdx.json \ | ||
| --type spdxjson \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api@${{ steps.push-api.outputs.digest }} | ||
|
|
||
| - name: Attest SBOM for Worker | ||
| run: | | ||
| cosign attest --yes \ | ||
| --predicate sbom-worker.spdx.json \ | ||
| --type spdxjson \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker@${{ steps.push-worker.outputs.digest }} | ||
|
|
||
| - name: Upload SBOMs as artefacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sbom-${{ steps.meta.outputs.version }} | ||
| path: "sbom-*.json" | ||
|
|
||
| - name: Verify API signature | ||
| run: | | ||
| cosign verify \ | ||
| --certificate-identity-regexp "https://github.com/${{ github.repository }}/.github/workflows/project-41-release.yml.*" \ | ||
| --certificate-oidc-issuer https://token.actions.githubusercontent.com \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-api@${{ steps.push-api.outputs.digest }} | ||
|
|
||
| - name: Verify Worker signature | ||
| run: | | ||
| cosign verify \ | ||
| --certificate-identity-regexp "https://github.com/${{ github.repository }}/.github/workflows/project-41-release.yml.*" \ | ||
| --certificate-oidc-issuer https://token.actions.githubusercontent.com \ | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/ai-worker@${{ steps.push-worker.outputs.digest }} | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| name: "[P41] Security Scanning" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [devops-project, master] | ||
| paths: | ||
| - "DevOps-Project-41/app/**" | ||
| - "DevOps-Project-41/k8s/**" | ||
| - ".github/workflows/project-41-security.yml" | ||
| schedule: | ||
| - cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| env: | ||
| APP_DIR: DevOps-Project-41/app | ||
|
|
||
| jobs: | ||
| trivy-filesystem: | ||
| name: Trivy Filesystem Scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
oleitao marked this conversation as resolved.
|
||
|
|
||
| - name: Run Trivy filesystem scan | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| scan-type: fs | ||
| scan-ref: DevOps-Project-41 | ||
| format: sarif | ||
| output: trivy-fs.sarif | ||
| severity: HIGH,CRITICAL | ||
| exit-code: "0" | ||
|
|
||
| - name: Upload SARIF to GitHub Security | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: trivy-fs.sarif | ||
| category: trivy-filesystem | ||
|
|
||
| trivy-config: | ||
| name: Trivy Kubernetes Manifest Scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run Trivy config scan on k8s manifests | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| scan-type: config | ||
| scan-ref: DevOps-Project-41/k8s | ||
| format: sarif | ||
| output: trivy-config.sarif | ||
| severity: HIGH,CRITICAL | ||
| exit-code: "0" | ||
|
|
||
| - name: Upload SARIF to GitHub Security | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: trivy-config.sarif | ||
| category: trivy-config | ||
|
|
||
| trivy-image: | ||
| name: Trivy Image Scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build API image for scanning | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ env.APP_DIR }} | ||
| file: ${{ env.APP_DIR }}/Dockerfile | ||
| target: api | ||
| push: false | ||
| load: true | ||
| tags: ai-api:scan | ||
| cache-from: type=gha | ||
|
|
||
| - name: Scan API image with Trivy | ||
| uses: aquasecurity/trivy-action@0.24.0 | ||
| with: | ||
| image-ref: ai-api:scan | ||
| format: sarif | ||
| output: trivy-image-api.sarif | ||
| severity: HIGH,CRITICAL | ||
| exit-code: "0" | ||
|
|
||
| - name: Upload API image SARIF | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: trivy-image-api.sarif | ||
| category: trivy-image-api | ||
|
|
||
| - name: Upload scan reports as artefacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: trivy-reports | ||
| path: "*.sarif" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.