Skip to content

Commit

Permalink
Run CI workflow on branch push
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Oct 18, 2024
1 parent c7c77b1 commit f03c684
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
28 changes: 10 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Main - Attests to https://app.kosli.com

on:
push:
branches:
- main

env:
KOSLI_DRY_RUN: ${{ vars.KOSLI_DRY_RUN }} # false
Expand Down Expand Up @@ -58,6 +56,7 @@ jobs:
pull-request:
if: ${{ github.ref == 'refs/heads/main' }}
needs: []
runs-on: ubuntu-latest
permissions:
Expand All @@ -70,13 +69,11 @@ jobs:
fetch-depth: 1

- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest pull-request evidence to Kosli
if: ${{ github.ref == 'refs/heads/main' }}
run:
kosli attest pullrequest github
--github-token=${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -161,6 +158,12 @@ jobs:
path: ${{ env.IMAGE_TAR_FILENAME }}
key: ${{ env.IMAGE_NAME }}

- name: Make Artifact fingerprint available to following jobs
id: variables
run: |
FINGERPRINT=$(echo ${{ steps.docker_build.outputs.digest }} | sed 's/.*://')
echo "artifact_digest=${FINGERPRINT}" >> ${GITHUB_OUTPUT}
- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/setup-cli-action@v2
Expand All @@ -174,12 +177,6 @@ jobs:
--artifact-type=docker
--name=runner

- name: Make Artifact fingerprint available to following jobs
id: variables
run: |
FINGERPRINT=$(kosli fingerprint "${{ env.IMAGE_NAME }}" --artifact-type=docker)
echo "artifact_digest=${FINGERPRINT}" >> ${GITHUB_OUTPUT}

unit-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -319,7 +316,7 @@ jobs:
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest Snyk container scan results to Kosli
- name: Attest evidence to Kosli
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }}
env:
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.artifact_digest }}
Expand Down Expand Up @@ -358,7 +355,7 @@ jobs:
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest Snyk code scan results to Kosli
- name: Attest evidence to Kosli
if: ${{ github.ref == 'refs/heads/main' && (success() || failure()) }}
env:
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.artifact_digest }}
Expand All @@ -369,17 +366,16 @@ jobs:


sdlc-control-gate:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [setup, build-image, pull-request, lint, unit-tests, integration-tests, snyk-container-scan, snyk-code-scan]
steps:
- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Kosli SDLC gate to short-circuit the workflow
if: ${{ github.ref == 'refs/heads/main' }}
env:
IMAGE_NAME: ${{ needs.setup.outputs.image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.artifact_digest }}
Expand All @@ -399,13 +395,11 @@ jobs:
fetch-depth: 0

- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest approval of deployment to Kosli
if: ${{ github.ref == 'refs/heads/main' }}
env:
IMAGE_NAME: ${{ needs.setup.outputs.image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.artifact_digest }}
Expand Down Expand Up @@ -436,13 +430,11 @@ jobs:
fetch-depth: 0

- name: Setup Kosli CLI
if: ${{ github.ref == 'refs/heads/main' }}
uses: kosli-dev/setup-cli-action@v2
with:
version: ${{ vars.KOSLI_CLI_VERSION }}

- name: Attest approval of deployment to Kosli
if: ${{ github.ref == 'refs/heads/main' }}
env:
IMAGE_NAME: ${{ needs.setup.outputs.image_name }}
KOSLI_FINGERPRINT: ${{ needs.build-image.outputs.artifact_digest }}
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
- An http service (rack based) for running `cyber-dojo.sh` inside a docker container for at most 20 seconds and returning `[stdout,stderr,status,timed_out,colour]`
- A [Kosli CI flow](https://app.kosli.com/cyber-dojo/flows/runner-ci/trails/)
deploying, with Continuous Compliance, to [staging](https://app.kosli.com/cyber-dojo/environments/aws-beta/snapshots/) and [production](https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/) AWS environments.

- Demonstrates a [Kosli](https://www.kosli.com/) instrumented [GitHub CI workflow](https://app.kosli.com/cyber-dojo/flows/runner-ci/trails/)
deploying, with Continuous Compliance, to [staging](https://app.kosli.com/cyber-dojo/environments/aws-beta/snapshots/) and [production](https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/) AWS environments.
- Uses patterns from https://www.kosli.com/blog/using-kosli-attest-in-github-action-workflows-some-tips/

***
API
Expand Down

0 comments on commit f03c684

Please sign in to comment.