|
| 1 | +name: Test Tools Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'test-tools/**' |
| 8 | + tags: |
| 9 | + - 'test-tools-v*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-push: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + id-token: write |
| 18 | + security-events: write |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up QEMU |
| 23 | + uses: docker/setup-qemu-action@v3 |
| 24 | + |
| 25 | + - uses: docker/setup-buildx-action@v3 |
| 26 | + |
| 27 | + - uses: docker/login-action@v3 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Determine tags |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@v5 |
| 36 | + with: |
| 37 | + images: ghcr.io/disentangle-network/test-tools |
| 38 | + tags: | |
| 39 | + type=match,pattern=test-tools-v(.*),group=1 |
| 40 | + type=raw,value=latest |
| 41 | +
|
| 42 | + - name: Build and push multi-arch image |
| 43 | + id: build |
| 44 | + uses: docker/build-push-action@v6 |
| 45 | + with: |
| 46 | + context: ./test-tools |
| 47 | + push: true |
| 48 | + platforms: linux/amd64,linux/arm64 |
| 49 | + tags: ${{ steps.meta.outputs.tags }} |
| 50 | + cache-from: type=gha |
| 51 | + cache-to: type=gha,mode=max |
| 52 | + |
| 53 | + - name: Run Trivy vulnerability scanner |
| 54 | + uses: aquasecurity/trivy-action@0.28.0 |
| 55 | + with: |
| 56 | + image-ref: ghcr.io/disentangle-network/test-tools:latest |
| 57 | + format: sarif |
| 58 | + output: trivy-results.sarif |
| 59 | + severity: CRITICAL,HIGH |
| 60 | + |
| 61 | + - name: Upload Trivy scan results |
| 62 | + uses: github/codeql-action/upload-sarif@v3 |
| 63 | + if: always() |
| 64 | + with: |
| 65 | + sarif_file: trivy-results.sarif |
| 66 | + |
| 67 | + - name: Install cosign |
| 68 | + uses: sigstore/cosign-installer@v3 |
| 69 | + |
| 70 | + - name: Sign image by digest |
| 71 | + env: |
| 72 | + COSIGN_EXPERIMENTAL: "true" |
| 73 | + run: | |
| 74 | + cosign sign --yes ghcr.io/disentangle-network/test-tools@${{ steps.build.outputs.digest }} |
| 75 | +
|
| 76 | + - name: Generate SBOM |
| 77 | + uses: anchore/sbom-action@v0 |
| 78 | + with: |
| 79 | + image: ghcr.io/disentangle-network/test-tools:latest |
| 80 | + format: spdx-json |
| 81 | + output-file: sbom.spdx.json |
| 82 | + |
| 83 | + - name: Attach SBOM to image |
| 84 | + run: | |
| 85 | + cosign attach sbom --sbom sbom.spdx.json ghcr.io/disentangle-network/test-tools@${{ steps.build.outputs.digest }} |
0 commit comments