Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/actions/common/lib-kosli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ function get_oldest_commit_sha
echo "$envJson" | jq -r '[.[] | .flows[]] | sort_by(.git_commit_info.timestamp) | .[0].git_commit_info.sha1'
}

function get_commits_between_tags
{
local -r oldTag=$1; shift
local -r newTag=$1; shift
git log --format="%H" --reverse ${oldTag}..${newTag}
}

function get_commits_between_staging_and_prod
{
Expand Down Expand Up @@ -98,3 +104,15 @@ function get_issue_keys_between_staging_and_prod
issueKeys=$(get_all_jira_issue_keys_for_commits ${flowName} "${commits}")
echo ${issueKeys} | tr ' ' '\n' | sort -u | tr '\n' ' '
}

function get_issue_keys_between_commits
{
local -r oldCommit=$1; shift
local -r newCommit=$1; shift
local -r flowName=$1; shift

commits=$(get_commits_between_tags ${oldCommit} ${newCommit})
debug_log "Commits between ${oldCommit} ${newCommit}:\n${commits}"
issueKeys=$(get_all_jira_issue_keys_for_commits ${flowName} "${commits}")
echo ${issueKeys} | tr ' ' '\n' | sort -u | tr '\n' ' '
}
47 changes: 47 additions & 0 deletions .github/actions/kosli-attest-jira-issues-list/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Kosli Attest Jira Issue List

# Attest a list of jira issues referred between two git commits

inputs:
# The Following environment variables must be set in your GitHub action
# before using this composite
# env:
# KOSLI_ORG: kosli
# KOSLI_FLOW: your-flow-name
# KOSLI_TRAIL: your-trail-name (often release ID)
# KOSLI_API_TOKEN: "${{ secrets.KOSLI_API_TOKEN }}"
# KOSLI_CLI_VERSION: 2.11.11
kosli-source-flow:
description: "Flow where Jira Issues are recorded"
old-commit:
description: "Oldest commit (will not be included)"
required: true
new-commit:
description: "Newest commit"
required: true

runs:
using: "composite"
steps:
- name: Setup Kosli cli
uses: kosli-dev/setup-cli-action@v2
with:
version:
${{ env.KOSLI_CLI_VERSION }}

- name: Attest Jira issue list
shell: bash
run: |
source ${GITHUB_ACTION_PATH}/../common/lib-kosli.sh
ISSUES=$(get_issue_keys_between_commits \
${{ inputs.old-commit }} ${{ inputs.new-commit }} \
${{ inputs.kosli-source-flow }})
echo ${ISSUES} | jq -R 'split(" ")' > /tmp/jira-issues.json

kosli attest custom \
--type=jira-issues-list \
--name jira-issues \
--attestation-data /tmp/jira-issues.json \
--annotate "JiraIssues=${ISSUES}"

echo "Jira issues: ${ISSUES}" >> $GITHUB_STEP_SUMMARY
30 changes: 5 additions & 25 deletions .github/workflows/setup-kosli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,13 @@ jobs:
# --template-file kosli-flow-templates/release-template.yml

### Custom attestation types ###
# - name: Create approval-jira attestation type
# run:
# kosli create attestation-type approval-jira
# --description "Approval from Jira. Must have at least 1 approver and all approvers must have APPROVED it"
# --schema custom-attestation-types/approval-jira-schema.json
# --jq '(.approvers | length) > 0'
# --jq '[.approvers[].status == "APPROVED"] | all'
#
# - name: Create running-sw attestation type
# run:
# kosli create attestation-type running-sw
# --description "List of running software in an environment"
# --schema custom-attestation-types/running-sw-schema.json
- name: Create running-sw attestation type
run:
kosli create attestation-type jira-issues-list
--description "List of Jira issues"
--schema custom-attestation-types/jira-issues-list-schema.json

### environments ###
# - name: Create dev env
# run:
# kosli create environment ${{ env.KOSLI_ENV_DEV }}
# --description "A simulated development environment"
# --type server
#
# - name: Create staging env
# run:
# kosli create environment ${{ env.KOSLI_ENV_STAGING }}
# --description "A simulated staging environment"
# --type server

- name: Create prod env
run:
kosli create environment ${{ env.KOSLI_ENV_PROD }}
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SHELL := bash

report_all_envs:
gh workflow run simulate-environment-reporting-prod.yml --ref main
19 changes: 19 additions & 0 deletions custom-attestation-types/jira-issues-list-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "JIRA Issues List",
"description": "A list of JIRA issue keys",
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z]+-[0-9]+$",
"description": "JIRA issue key in format PROJECT-NUMBER (e.g., MRJP-4)"
},
"minItems": 0,
"uniqueItems": true,
"examples": [
[],
["MRJP-4"],
["MRJP-4", "MRJP-5"],
["ABC-123", "XYZ-456", "TEST-1"]
]
}