|
| 1 | +name: Blackduck SCA Scan |
| 2 | +on: |
| 3 | + #push: |
| 4 | + # branches: [ "main" ] |
| 5 | + #pull_request: |
| 6 | + # branches: [ "main" ] |
| 7 | + schedule: |
| 8 | + - cron: '8 0 * * 0' |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + checks: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: [ ubuntu-latest ] |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 21 | + |
| 22 | + - name: Setup Go |
| 23 | + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 |
| 24 | + with: |
| 25 | + go-version-file: '${{ github.workspace }}/go.mod' |
| 26 | + cache: false |
| 27 | + |
| 28 | + - name: Get go environment for use with cache |
| 29 | + run: | |
| 30 | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV |
| 31 | + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV |
| 32 | + # This step will only reuse the go mod and build cache from main made during the Build, |
| 33 | + # see push_ocm.yaml => "ocm-cli-latest" Job |
| 34 | + # This means it never caches by itself and PRs cannot cause cache pollution / thrashing |
| 35 | + # This is because we have huge storage requirements for our cache because of the mass of dependencies |
| 36 | + |
| 37 | + - name: Restore / Reuse Cache from central build |
| 38 | + id: cache-golang-restore |
| 39 | + uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # Only Restore, not build another cache (too big) |
| 40 | + with: |
| 41 | + path: | |
| 42 | + ${{ env.go_cache }} |
| 43 | + ${{ env.go_modcache }} |
| 44 | + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ env.cache_name }}-${{ runner.os }}-go- |
| 47 | + env: |
| 48 | + cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step |
| 49 | + |
| 50 | + - name: Run Black Duck Full SCA Scan (Manual Trigger and Scheduled) |
| 51 | + if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' |
| 52 | + uses: blackduck-inc/black-duck-security-scan@805cbd09e806b01907bbea0f990723c2bb85abe9 |
| 53 | + env: |
| 54 | + DETECT_PROJECT_USER_GROUPS: opencomponentmodel |
| 55 | + DETECT_PROJECT_VERSION_DISTRIBUTION: opensource |
| 56 | + DETECT_SOURCE_PATH: ./ |
| 57 | + DETECT_EXCLUDED_DIRECTORIES: .bridge |
| 58 | + DETECT_BLACKDUCK_SIGNATURE_SCANNER_ARGUMENTS: '--min-scan-interval=0' |
| 59 | + NODE_TLS_REJECT_UNAUTHORIZED: true |
| 60 | + with: |
| 61 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + blackducksca_url: ${{ secrets.BLACKDUCK_URL }} |
| 63 | + blackducksca_token: ${{ secrets.BLACKDUCK_API_TOKEN }} |
| 64 | + blackducksca_scan_full: true |
| 65 | + |
| 66 | + - name: Run Black Duck SCA Scan (Pull Request or Push) |
| 67 | + if: github.event_name != 'workflow_dispatch' |
| 68 | + # The action sets blackducksca_scan_full internally: for pushes to true and PRs to false |
| 69 | + uses: blackduck-inc/[email protected] |
| 70 | + env: |
| 71 | + DETECT_PROJECT_USER_GROUPS: opencomponentmodel |
| 72 | + DETECT_PROJECT_VERSION_DISTRIBUTION: opensource |
| 73 | + DETECT_SOURCE_PATH: ./ |
| 74 | + DETECT_EXCLUDED_DIRECTORIES: .bridge |
| 75 | + NODE_TLS_REJECT_UNAUTHORIZED: true |
| 76 | + with: |
| 77 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + blackducksca_url: ${{ secrets.BLACKDUCK_URL }} |
| 79 | + blackducksca_token: ${{ secrets.BLACKDUCK_API_TOKEN }} |
| 80 | + blackducksca_prComment_enabled: true |
0 commit comments