Skip to content

Commit 15865d9

Browse files
authored
CLOUDP-319858: Auto-update SBOM report in codebase (#3902)
1 parent 15841bc commit 15865d9

File tree

4 files changed

+134
-21
lines changed

4 files changed

+134
-21
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Update Compliance Report
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'atlascli tag version (e.g. 1.42.2)'
10+
required: true
11+
type: string
12+
13+
jobs:
14+
update-compliance-report:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
18+
with:
19+
config: ${{ vars.PERMISSIONS_CONFIG }}
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Extract AUTHOR and VERSION
23+
id: extract
24+
run: |
25+
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
26+
# Expect input like 'atlascli/v1.42.2' or '1.42.2'
27+
TAG="${{ github.event.inputs.tag }}"
28+
VERSION="${TAG#atlascli/v}"
29+
AUTHOR="${{ github.actor }}"
30+
else
31+
# GITHUB_REF is refs/tags/atlascli/v1.42.2
32+
VERSION="${GITHUB_REF#refs/tags/atlascli/v}"
33+
AUTHOR="${{ github.event.release.author.login }}"
34+
fi
35+
echo "author=$AUTHOR" >> "$GITHUB_OUTPUT"
36+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
37+
- name: Run gen-ssdlc-report.sh
38+
env:
39+
AUTHOR: ${{ steps.extract.outputs.author }}
40+
VERSION: ${{ steps.extract.outputs.version }}
41+
run: ./build/package/gen-ssdlc-report.sh
42+
- name: set Apix Bot token
43+
id: app-token
44+
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42
45+
with:
46+
app-id: ${{ secrets.APIXBOT_APP_ID }}
47+
private-key: ${{ secrets.APIXBOT_APP_PEM }}
48+
- name: Find JIRA ticket
49+
id: find
50+
uses: mongodb/apix-action/find-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42
51+
with:
52+
token: ${{ secrets.JIRA_API_TOKEN }}
53+
jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Compliance Report"
54+
- name: Set JIRA ticket (find)
55+
if: steps.find.outputs.found == 'true'
56+
run: |
57+
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV"
58+
- name: Create JIRA ticket
59+
uses: mongodb/apix-action/create-jira@3024080388613583e3bd119bfb1ab4b4dbf43c42
60+
id: create
61+
if: steps.find.outputs.found == 'false'
62+
with:
63+
token: ${{ secrets.JIRA_API_TOKEN }}
64+
project-key: CLOUDP
65+
summary: "[AtlasCLI] Update Compliance Report"
66+
issuetype: Story
67+
description: Update Compliance Report
68+
components: AtlasCLI
69+
assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
70+
extra-data: |
71+
{
72+
"fields": {
73+
"fixVersions": [
74+
{
75+
"id": "41805"
76+
}
77+
],
78+
"customfield_12751": [
79+
{
80+
"id": "22223"
81+
}
82+
],
83+
"customfield_10257": {
84+
"id": "11861"
85+
}
86+
}
87+
}
88+
- name: Set JIRA ticket (create)
89+
if: steps.find.outputs.found == 'false'
90+
run: |
91+
echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV"
92+
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
93+
id: pr
94+
with:
95+
token: ${{ steps.app-token.outputs.token }}
96+
committer: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>"
97+
author: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>"
98+
title: "${{ env.JIRA_KEY }}: Update compliance report for v${{ steps.extract.outputs.version }}"
99+
commit-message: "${{ env.JIRA_KEY }}: Update compliance report for v${{ steps.extract.outputs.version }}"
100+
delete-branch: true
101+
base: master
102+
branch: ${{ env.JIRA_KEY }}
103+
labels: |
104+
compliance
105+
auto
106+
auto_close_jira
107+
body: |
108+
## Proposed changes
109+
Update compliance report for v${{ steps.extract.outputs.version }}
110+
_Jira ticket:_ ${{ env.JIRA_KEY }}
111+
112+
Note: Jira ticket will be closed automatically when this PR is merged.
113+
114+
- name: Set auto merge
115+
env:
116+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
117+
run: |
118+
gh pr merge "${{ steps.pr.outputs.pull-request-url }}" --auto --squash

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*.so
66
*.dylib
77
bin/**
8-
compliance/**
98
dist/**
109
# mac notarization service
1110
linux_amd64/**

build/ci/release.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ functions:
112112
--repo mongodb_mongodb-atlas-cli \
113113
--branch ${branch_name}
114114
rm ${workdir}/kondukto_credentials.env
115-
"generate ssdlc report":
116-
- command: subprocess.exec
117-
params:
118-
include_expansions_in_env:
119-
- author
120-
env:
121-
AUTHOR: ${author}
122-
<<: *go_options
123-
binary: build/package/gen-ssdlc-report.sh
124115
"package":
125116
- command: github.generate_token
126117
params:
@@ -404,7 +395,6 @@ tasks:
404395
commands:
405396
- func: "generate sbom"
406397
- func: "run silkbomb"
407-
- func: "generate ssdlc report"
408398
- name: package_goreleaser
409399
tags: ["packaging"]
410400
depends_on:

build/package/gen-ssdlc-report.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,28 @@ set -eu
1919
release_date=${DATE:-$(date -u '+%Y-%m-%d')}
2020

2121
export DATE="${release_date}"
22-
VERSION=""
23-
VERSION=$(git tag --list 'atlascli/v*' --sort=-taggerdate | head -1 | cut -d 'v' -f 2)
22+
23+
if [ -z "${AUTHOR:-}" ]; then
24+
AUTHOR=$(git config user.name)
25+
fi
26+
27+
if [ -z "${VERSION:-}" ]; then
28+
VERSION=$(git tag --list 'atlascli/v*' --sort=-taggerdate | head -1 | cut -d 'v' -f 2)
29+
fi
30+
31+
export AUTHOR
2432
export VERSION
25-
export AUTHOR="${AUTHOR:-$(git config user.name)}"
2633

2734
echo "Generating SSDLC checklist for AtlasCLI version ${VERSION}, author ${AUTHOR} and release date ${DATE}..."
2835

29-
# Ensure compliance directory exists
30-
mkdir -p "compliance/"
36+
# Ensure AtlasCLI version directory exists
37+
mkdir -p "compliance/v${VERSION}"
3138

32-
# Generate the report in compliance/ with a versioned filename
3339
envsubst < docs/releases/ssdlc-compliance.template.md \
34-
> "compliance/ssdlc-compliance-${VERSION}.md"
40+
> "compliance/v${VERSION}/ssdlc-compliance-${VERSION}.md"
3541

36-
echo "SDLC checklist ready. Files in compliance/:"
37-
ls -l "compliance/"
42+
echo "SDLC checklist ready. Files in compliance/v${VERSION}/:"
43+
ls -l "compliance/v${VERSION}/"
3844

3945
echo "Printing the generated report:"
40-
cat "compliance/ssdlc-compliance-${VERSION}.md"
46+
cat "compliance/v${VERSION}/ssdlc-compliance-${VERSION}.md"

0 commit comments

Comments
 (0)