Skip to content

Commit cc500ab

Browse files
committed
testing cisagov#717, refactoring github build workflows
1 parent 6eee8bd commit cc500ab

File tree

2 files changed

+10
-111
lines changed

2 files changed

+10
-111
lines changed

.github/workflows/dashboards-build-and-push-ghcr.yml

Lines changed: 4 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -26,107 +26,7 @@ on:
2626

2727
jobs:
2828
docker:
29-
runs-on: ${{ matrix.os }}
30-
permissions:
31-
actions: write
32-
packages: write
33-
contents: read
34-
security-events: write
35-
strategy:
36-
fail-fast: false
37-
matrix:
38-
include:
39-
- os: ubuntu-24.04
40-
arch: amd64
41-
platform: linux/amd64
42-
- os: ubuntu-24.04-arm
43-
arch: arm64
44-
platform: linux/arm64
45-
steps:
46-
-
47-
name: Cancel previous run in progress
48-
uses: styfle/cancel-workflow-action@0.12.1
49-
with:
50-
ignore_sha: true
51-
all_but_latest: true
52-
access_token: ${{ secrets.GITHUB_TOKEN }}
53-
-
54-
name: Checkout
55-
uses: actions/checkout@v4
56-
-
57-
name: Generate build timestamp
58-
shell: bash
59-
run: echo "btimestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
60-
id: generate_build_timestamp
61-
-
62-
name: Extract branch name
63-
shell: bash
64-
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
65-
id: extract_branch
66-
-
67-
name: Generate arch tag suffix
68-
shell: bash
69-
run: echo "archtag=$([[ "${{ matrix.platform }}" == 'linux/amd64' ]] && echo '' || ( echo -n '-' ; echo "${{ matrix.platform }}" | cut -d '/' -f 2) )" >> $GITHUB_OUTPUT
70-
id: arch_tag_suffix
71-
-
72-
name: Extract commit SHA
73-
shell: bash
74-
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
75-
id: extract_commit_sha
76-
-
77-
name: Extract Malcolm version
78-
shell: bash
79-
run: echo "mversion=$(grep -P "^\s+image:.*/malcolm/" docker-compose-dev.yml | awk '{print $2}' | cut -d':' -f2 | uniq -c | sort -nr | awk '{print $2}' | head -n 1)" >> $GITHUB_OUTPUT
80-
id: extract_malcolm_version
81-
-
82-
name: Set up Docker Buildx
83-
uses: docker/setup-buildx-action@v3
84-
with:
85-
driver-opts: |
86-
image=moby/buildkit:master
87-
-
88-
name: Log in to registry
89-
uses: docker/login-action@v3
90-
with:
91-
registry: ghcr.io
92-
username: ${{ github.repository_owner }}
93-
password: ${{ secrets.GITHUB_TOKEN }}
94-
-
95-
name: Build and push
96-
uses: docker/build-push-action@v6
97-
with:
98-
context: .
99-
file: ./Dockerfiles/dashboards.Dockerfile
100-
build-args: |
101-
TARGETPLATFORM=${{ matrix.platform }}
102-
MALCOLM_VERSION=${{ steps.extract_malcolm_version.outputs.mversion }}
103-
BUILD_DATE=${{ steps.generate_build_timestamp.outputs.btimestamp }}
104-
VCS_REVISION=${{ steps.extract_commit_sha.outputs.sha }}
105-
push: true
106-
provenance: false
107-
platforms: ${{ matrix.platform }}
108-
tags: ghcr.io/${{ github.repository_owner }}/malcolm/dashboards:${{ steps.extract_branch.outputs.branch }}${{ steps.arch_tag_suffix.outputs.archtag }}
109-
-
110-
name: Run Trivy vulnerability scanner
111-
if: ${{ matrix.platform == 'linux/amd64' }}
112-
id: trivy-scan
113-
uses: aquasecurity/trivy-action@0.29.0
114-
env:
115-
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
116-
with:
117-
scan-type: 'image'
118-
scanners: 'vuln'
119-
image-ref: ghcr.io/${{ github.repository_owner }}/malcolm/dashboards:${{ steps.extract_branch.outputs.branch }}${{ steps.arch_tag_suffix.outputs.archtag }}
120-
format: 'sarif'
121-
output: 'trivy-results.sarif'
122-
severity: 'HIGH,CRITICAL'
123-
vuln-type: 'os,library'
124-
hide-progress: true
125-
ignore-unfixed: true
126-
exit-code: '0'
127-
-
128-
name: Upload Trivy scan results to GitHub Security tab
129-
if: ${{ matrix.platform == 'linux/amd64' }}
130-
uses: github/codeql-action/upload-sarif@v3
131-
with:
132-
sarif_file: 'trivy-results.sarif'
29+
uses: ./.github/workflows/docker-build-push-scan.yml
30+
with:
31+
service: dashboards
32+
dockerfile: ./Dockerfiles/dashboards.Dockerfile

.github/workflows/docker-build-push-scan.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ on:
99
dockerfile:
1010
required: true
1111
type: string
12-
maxmind_license_key:
12+
extra_build_args:
1313
required: false
1414
type: string
15-
maxmind_alternate_url:
15+
secrets:
16+
maxmind_license_key:
1617
required: false
17-
type: string
18-
extra_build_args:
18+
maxmind_alternate_url:
1919
required: false
20-
type: string
2120

2221
jobs:
2322
docker:
@@ -98,9 +97,9 @@ jobs:
9897
MALCOLM_VERSION=${{ steps.extract_malcolm_version.outputs.mversion }}
9998
BUILD_DATE=${{ steps.generate_build_timestamp.outputs.btimestamp }}
10099
VCS_REVISION=${{ steps.extract_commit_sha.outputs.sha }}
100+
${{ secrets.maxmind_license_key && format('MAXMIND_GEOIP_DB_LICENSE_KEY={0}', secrets.maxmind_license_key) || '' }}
101+
${{ secrets.maxmind_alternate_url && format('MAXMIND_GEOIP_DB_ALTERNATE_DOWNLOAD_URL={0}', secrets.maxmind_alternate_url) || '' }}
101102
${{ inputs.extra_build_args || '' }}
102-
${{ inputs.maxmind_license_key && format('MAXMIND_GEOIP_DB_LICENSE_KEY={0}', inputs.maxmind_license_key) || '' }}
103-
${{ inputs.maxmind_alternate_url && format('MAXMIND_GEOIP_DB_ALTERNATE_DOWNLOAD_URL={0}', inputs.maxmind_alternate_url) || '' }}
104103
push: true
105104
provenance: false
106105
platforms: ${{ matrix.platform }}

0 commit comments

Comments
 (0)