Skip to content

Commit

Permalink
SNYK container scan integrated into build workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatadorisala12 authored and prabhakarreddy1234 committed Sep 9, 2022
1 parent e5b59cc commit 0d11d89
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
name: Build
needs: [setup]
runs-on: ubuntu-latest
environment:
name: dev

outputs:
authserver: ${{ steps.image_tags.outputs.authserver }}
Expand Down Expand Up @@ -110,28 +112,62 @@ jobs:
echo ::set-output name=authserver::$CONTAINER_REGISTRY/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]'):authserver-$GITHUB_SHA
echo ::set-output name=testclient::$CONTAINER_REGISTRY/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]'):testclient-$GITHUB_SHA
- name: Set KV environment variables
working-directory: terraform
if: github.actor != 'dependabot[bot]'
run: |
tf_vars_file=workspace_variables/dev.tfvars.json
echo "KEY_VAULT_NAME=$(jq -r '.key_vault_name' ${tf_vars_file})" >> $GITHUB_ENV
- uses: azure/login@v1
if: github.actor != 'dependabot[bot]'
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- uses: DFE-Digital/keyvault-yaml-secret@v1
if: github.actor != 'dependabot[bot]'
id: get-secret
with:
keyvault: ${{ env.KEY_VAULT_NAME }}
secret: INFRASTRUCTURE
key: SNYK_TOKEN

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: AuthServer Docker build & push
uses: docker/build-push-action@v2
- name: Auth server docker build
uses: docker/build-push-action@v3
with:
context: dotnet-authserver/src/TeacherIdentity.AuthServer
push: true
push: false
tags: ${{ steps.image_tags.outputs.authserver }}
build-args: |
GIT_SHA=${{ github.sha }}
- name: TestClient Docker build & push
uses: docker/build-push-action@v2
- name: Run Snyk to check auth server Docker image for vulnerabilities
if: github.actor != 'dependabot[bot]'
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ steps.get-secret.outputs.snyk_token }}
with:
image: ${{ steps.image_tags.outputs.authserver }}
args: --file=dotnet-authserver/src/TeacherIdentity.AuthServer/Dockerfile --severity-threshold=high

- name: Push auth server docker image
run: docker image push ${{ steps.image_tags.outputs.authserver }}

- name: Test client docker build
uses: docker/build-push-action@v3
with:
context: dotnet-authserver/src/TeacherIdentity.TestClient
push: true
tags: ${{ steps.image_tags.outputs.testclient }}
build-args: |
GIT_SHA=${{ github.sha }}
validate_terraform:
name: Validate Terraform
Expand Down Expand Up @@ -237,4 +273,3 @@ jobs:
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
terraform_vars: workspace_variables/production.tfvars.json
terraform_backend_vars: workspace_variables/production.backend.tfvars

0 comments on commit 0d11d89

Please sign in to comment.