|
26 | 26 |
|
27 | 27 | jobs: |
28 | 28 | 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 |
0 commit comments