Skip to content

Commit b94c08e

Browse files
Feat/dtoss 8958 publish to GitHub (#182)
* new CI workflow template * YAML syntax * move from expression to shell logic * Provide required parameters from the CI pipeline Add outputs references * Correct path reference in uses * Refactor in new GitHub actions * Use case-insensitive checks * added ghcr.io logins * Support for the change_folders environment variable * registry interpolation is readable * one line conditional * quote string comparison * thread the azurecr retagging * more than 30 items returned in gh api packages call * workflow consumes templates from working branch * GitHub action reference paths * more concise way to enforce lower case registry name * Improved job name * fail-fast false, simplify tagging: scrap env tag, tag initially with PR only, then later all images are tagged with merge commit hash * azurecr login doesn't need its own step * fix ghcr.io tagging console output * Dump directory structure before SBOM * Include subdirectories in the directory list * Update directory list to list YAML / Dockerfile * Update to find expression * templates repo path for new GitHub Actions * Add bash command * execute permission on scripts * explicitly use bash for scripts * fix container names for SBOM, vulnerabilities scanning, remove redundant inputs * debug SBOM file paths * SBOM report upload fix * SBOM action output definition * SBOM action artifact * Fetch tag metadata outside matrix job * Token not needed * needs dependency fixed * use needs inline * Determine PR number * Work on PR Number * PR-tag-logic * Test deployment to GitHub * Ensure that we can push with environment tag is specified * name workflow jobs * Outputs on containers-to-build Remove duplicate fetch tag metadata Build Docker Images has an id for repository_path Set output for docker_compose_dir * Fix incorrect repository reference * Set repository path * Update to ensure test on GitHub * Additional output to ensure buildx occurs * Add support to test deployment on last job * Test for access to the GH repo before accessing all packages * Lowercase requirement for repository * Filter first gh api by container type * Update ref Add sample query to view output from github api * Add tag for short commit hash Remove unnecessary step 1b in get_docker_names * Return all docker services for updates to tags * Residual array reference * Improved handling of array from bash script * Testing the manifest overwrites of buildx * Test azure repo integration * Test azure containers * Fix reference to acr name * Update Azure login step * Case sensitive casing for images * Improve naming convention for clearer understanding Remove redundant step for buildx Ensure az acr login uses correct reference * Test this with GitHub * One final run for Github * Improve naming convention for clearer understanding Remove redundant step for buildx Ensure az acr login uses correct reference * Remove test_deployment reference Case sensitivity * Final commit * Updates to remove unneeded changes * Remove unneeded bash script file. * Revert parameters to first iteration * Update to use case-sensitive folder check --------- Co-authored-by: patrickmoore-nc <[email protected]>
1 parent d133450 commit b94c08e

File tree

4 files changed

+349
-45
lines changed

4 files changed

+349
-45
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Software Bill of Materials Report
2+
description: Generates and uploads an SBOM report for the specified Docker image.
3+
4+
inputs:
5+
build_datetime:
6+
description: Build datetime, set by the CI/CD pipeline workflow
7+
required: true
8+
build_timestamp:
9+
description: Build timestamp, set by the CI/CD pipeline workflow
10+
required: true
11+
image_name:
12+
description: Docker Image to be scanned
13+
required: true
14+
15+
outputs:
16+
sbom_repository_report:
17+
value: ${{ steps.report.outputs.sbom_repository_report }}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Create SBOM report
23+
id: report
24+
shell: bash
25+
env:
26+
BUILD_DATETIME: ${{ inputs.build_datetime }}
27+
SBOM_REPOSITORY_REPORT: ${{ inputs.image_name }}-sbom
28+
CHECK_DOCKER_IMAGE: ${{ inputs.image_name }}:latest
29+
FORCE_USE_DOCKER: true
30+
run: |
31+
mkdir sbom
32+
echo "sbom_repository_report=${SBOM_REPOSITORY_REPORT}" >> ${GITHUB_OUTPUT}
33+
bash ${GITHUB_WORKSPACE}/templates/scripts/reports/create-sbom-report.sh
34+
35+
- name: Upload SBOM report as an artefact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: ${{ inputs.image_name }}-sbom
39+
path: ${{ inputs.image_name }}-sbom.json
40+
retention-days: 21
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Vulnerabilities Report
2+
description: Generates and uploads a vulnerability report from an SBOM for the given image.
3+
4+
inputs:
5+
build_datetime:
6+
description: Build datetime, set by the CI/CD pipeline workflow
7+
required: true
8+
build_timestamp:
9+
description: Build timestamp, set by the CI/CD pipeline workflow
10+
required: true
11+
image_name:
12+
description: Docker Image to be scanned
13+
required: true
14+
sbom_repository_report:
15+
description: File path of SBOM report
16+
required: true
17+
18+
runs:
19+
using: composite
20+
21+
steps:
22+
- name: Create vulnerabilites report
23+
shell: bash
24+
env:
25+
BUILD_DATETIME: ${{ inputs.build_datetime }}
26+
CHECK_DOCKER_IMAGE: ${{ inputs.image_name }}:latest
27+
FORCE_USE_DOCKER: true
28+
VULNERABILITIES_REPOSITORY_REPORT: ${{ inputs.image_name }}-vulnerabilities-repository-report
29+
VULNERABILITIES_SUMMARY_LOGFILE: ${{ inputs.image_name }}-vulnerabilities-summary.txt
30+
SBOM_REPOSITORY_REPORT: ${{ inputs.sbom_repository_report }}
31+
run: |
32+
mkdir vulnerabilities
33+
bash -x ${GITHUB_WORKSPACE}/templates/scripts/reports/scan-vulnerabilities.sh
34+
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sudo sh -s -- -b /usr/local/bin
35+
36+
SCAN_RESULTS=$(grype "${CHECK_DOCKER_IMAGE}" --scope all-layers)
37+
echo "${SCAN_RESULTS}" > "vulnerabilities/${VULNERABILITIES_REPOSITORY_REPORT}.json"
38+
39+
# ANSI color codes
40+
RED="\033[0;31m"
41+
RESET="\033[0m"
42+
43+
# Clear existing log file (or create if it doesn't exist)
44+
> "vulnerabilities/${VULNERABILITIES_SUMMARY_LOGFILE}"
45+
46+
for SEVERITY in CRITICAL HIGH MEDIUM; do
47+
{
48+
echo
49+
echo "${CHECK_DOCKER_IMAGE}: vulnerabilities"
50+
echo -e "=== ${RED}${SEVERITY}${RESET} Vulnerabilities list ==="
51+
# If grep finds nothing, we print a fallback message
52+
echo "${SCAN_RESULTS}" | grep -i "${SEVERITY}" || echo "No ${SEVERITY} vulnerabilities found."
53+
} | tee -a "vulnerabilities/${VULNERABILITIES_SUMMARY_LOGFILE}"
54+
done
55+
- name: Upload vulnerabilities report
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: ${{ inputs.image_name }}-vulnerabilities
59+
path: |
60+
vulnerabilities/${{ inputs.image_name }}-vulnerabilities-repository-report.json
61+
vulnerabilities/${{ inputs.image_name }}-vulnerabilities-summary.txt
62+
retention-days: 21

0 commit comments

Comments
 (0)