-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add tutorial for publishing trail summaries to GitHub and GitLab CI #274
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2800147
docs: add tutorial for publishing trail summaries to GitHub and GitLa…
mintlify[bot] 628b506
docs: add tutorial for publishing trail summaries to GitHub and GitLa…
mintlify[bot] 87a81d0
docs: bump actions to latest (checkout@v5, setup-cli-action@v5)
mintlify[bot] 7829e1b
docs: bump actions/checkout to v7
mintlify[bot] 0199796
docs: address GitLab review feedback on trail summaries tutorial
mintlify[bot] 8998d14
refactor: use Kosli Alpine runner image in GitLab tutorial job
mintlify[bot] 16ffa89
docs: bump kosli-runner image tag to 2.28.0
mintlify[bot] c3fa1f7
docs: stabilize GitLab expose_as link, annotate image tag, bump ci_cd…
mintlify[bot] 4061f42
chore: bump kosli-dev/setup-cli-action to v5 across docs
mintlify[bot] 474a835
chore: bump actions/checkout to v7 across docs
mintlify[bot] 20139f8
chore: strip backticks from tutorial description and bump pinned CLI …
mintlify[bot] 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
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
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
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
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
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
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
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,118 @@ | ||
| --- | ||
| title: "Adding trail summaries to CI pipeline runs" | ||
| description: "Use kosli get trail --output markdown to publish a Kosli trail summary directly to GitHub Actions and GitLab CI pipeline runs." | ||
| --- | ||
|
|
||
| `kosli get trail --output markdown` renders a trail as GitHub-Flavored Markdown — compliance state, git commit, attestation statuses, and events, with links back to the Kosli app. Pipe it into your CI's job summary and every pipeline run becomes an information radiator for the trail it produced. | ||
|
|
||
| By the end of this tutorial, you will have added a Kosli trail summary to a GitHub Actions job summary and to a GitLab CI pipeline. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| * [Install Kosli CLI](/getting_started/install) on your CI runner (e.g. via [`kosli-dev/setup-cli-action`](https://github.com/marketplace/actions/setup-kosli-cli) on GitHub). | ||
| * A flow and trail you are already reporting to during the pipeline. See [Querying Kosli](/tutorials/querying_kosli) if you need to find the flow and trail name. | ||
| * `KOSLI_API_TOKEN` and `KOSLI_ORG` available to the job (see [Authenticating to Kosli](/getting_started/authenticating_to_kosli)). | ||
|
|
||
| ## What the markdown output looks like | ||
|
|
||
| Run the command locally first to see what will end up in your CI summary: | ||
|
|
||
| ```shell | ||
| kosli get trail my-trail-name --flow my-flow --output markdown | ||
| ``` | ||
|
|
||
| The output is a markdown document with: | ||
|
|
||
| - A `## Trail: <name>` heading linked to the trail page in the Kosli app. | ||
| - A metadata table (name, description, compliance, last modified, origin). | ||
| - A `### Git commit` table with the commit author, timestamp, and subject. | ||
| - An `### Attestations` section with one headerless table per artifact (and one for trail-level attestations), with each attestation linked to its place on the trail page. Statuses are prefixed with ✅ / ❌ / ⏳; attestations reported but not expected by the template are marked with `(+)`. | ||
| - An `### Events` table with timestamps, descriptions, commit links, and compliance state. | ||
|
|
||
| ## Publishing the summary | ||
|
|
||
| <Tabs> | ||
| <Tab title="GitHub" icon="github"> | ||
|
|
||
| GitHub Actions exposes a per-job markdown summary via the [`$GITHUB_STEP_SUMMARY`](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) environment variable. Anything you append to that file is rendered on the workflow run page. | ||
|
|
||
| Add a final step to your job that writes the trail summary to it: | ||
|
|
||
| ```yaml | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }} | ||
| KOSLI_ORG: my-org | ||
| KOSLI_FLOW: my-flow | ||
| KOSLI_TRAIL: ${{ github.sha }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
mbevc1 marked this conversation as resolved.
mbevc1 marked this conversation as resolved.
|
||
|
|
||
| - name: Setup Kosli CLI | ||
| uses: kosli-dev/setup-cli-action@v5 | ||
|
mbevc1 marked this conversation as resolved.
|
||
|
|
||
| # ... your build, attest, and report steps ... | ||
|
|
||
| - name: Publish Kosli trail summary | ||
| if: always() | ||
| run: | | ||
| kosli get trail "$KOSLI_TRAIL" \ | ||
| --flow "$KOSLI_FLOW" \ | ||
| --output markdown >> "$GITHUB_STEP_SUMMARY" | ||
| ``` | ||
|
|
||
| `if: always()` makes sure the summary is published even when an earlier step fails — that is when you most want to see which attestation is missing or non-compliant. | ||
|
|
||
| The summary appears on the run's page under the job, with the trail name linking back to the trail in the Kosli app and every attestation linking to its position on the trail. | ||
|
|
||
| </Tab> | ||
| <Tab title="GitLab" icon="gitlab"> | ||
|
|
||
| GitLab does not natively render markdown inline on the job page, but [`artifacts:expose_as`](https://docs.gitlab.com/ci/yaml/artifacts/#expose_as) surfaces the `summary.md` artifact as a labeled link in the merge request widget, one click away from the rendered file in the GitLab UI. | ||
|
mbevc1 marked this conversation as resolved.
|
||
|
|
||
| Add a job (or a final step in your existing job) that produces that artifact. Use the [Kosli Alpine CI runner image](/integrations/ci_cd#ci-runner-image-alpine) so `kosli`, `git`, and `curl` are preinstalled and no `before_script` setup is needed: | ||
|
|
||
| ```yaml | ||
| kosli-trail-summary: | ||
| stage: .post | ||
| image: registry.example.com/ci/kosli-runner:2.28.0 # replace with the tag you pushed | ||
| variables: | ||
| KOSLI_FLOW: my-flow | ||
| KOSLI_TRAIL: $CI_COMMIT_SHA | ||
| script: | ||
| - > | ||
| kosli get trail "$KOSLI_TRAIL" | ||
| --flow "$KOSLI_FLOW" | ||
|
mbevc1 marked this conversation as resolved.
|
||
| --output markdown > summary.md | ||
| artifacts: | ||
| when: always | ||
| paths: | ||
| - summary.md | ||
| expose_as: "Kosli trail summary" | ||
| ``` | ||
|
|
||
| Replace `registry.example.com/ci/kosli-runner:2.28.0` with whatever tag you pushed when you built the Alpine image — see [CI runner image (Alpine)](/integrations/ci_cd#ci-runner-image-alpine) for the build steps. | ||
|
|
||
| `KOSLI_API_TOKEN` and `KOSLI_ORG` should be set as [CI/CD variables](https://docs.gitlab.com/ci/variables/) on the project or group, masked, so the job picks them up automatically. | ||
|
|
||
| `when: always` mirrors the GitHub `if: always()` pattern: the summary is uploaded even if earlier stages fail. | ||
|
|
||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| ## Tips | ||
|
|
||
| - Pin a specific trail by exporting `KOSLI_TRAIL` early in the pipeline (commonly to the commit SHA you used in `kosli begin trail`). Every later step — including the summary — then targets the same trail. | ||
| - The markdown output is stable text. You can also commit it as a build artifact or attach it to a release for an audit-friendly record of what was reported for that build. | ||
| - Run `kosli get trail --output markdown` locally against a real trail before wiring it into CI. It is the fastest way to see what your team will see on the pipeline page. | ||
|
|
||
| ## What you've accomplished | ||
|
|
||
| You have published a live Kosli trail summary — compliance state, attestations, and events — directly onto your GitHub Actions and GitLab CI pipeline pages, turning every build into a feedback channel for the trail it produced. | ||
|
|
||
| From here you can: | ||
|
|
||
| - Read the full [`kosli get trail`](/client_reference/kosli_get_trail) reference. | ||
| - Browse other [CI/CD integration patterns](/integrations/ci_cd). | ||
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.