|
| 1 | +name: Checkov |
| 2 | + |
| 3 | +# Controls when the workflow will run |
| 4 | +on: |
| 5 | + # Triggers the workflow on push or pull request events but only for the "main" branch |
| 6 | + push: |
| 7 | + branches: [ "main" ] |
| 8 | + pull_request: |
| 9 | + branches: [ "main" ] |
| 10 | + |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +# global permissions |
| 15 | +permissions: read-all |
| 16 | + |
| 17 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 18 | +jobs: |
| 19 | + # This workflow contains a single job called "scan" |
| 20 | + scan: |
| 21 | + permissions: |
| 22 | + contents: read # for actions/checkout to fetch code |
| 23 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 24 | + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 25 | + |
| 26 | + # The type of runner that the job will run on |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 30 | + steps: |
| 31 | + # Checks-out your repository under $GITHUB_WORKSPACE, so follow-up steps can access it |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Checkov GitHub Action |
| 35 | + uses: bridgecrewio/checkov-action@v12 |
| 36 | + with: |
| 37 | + # This will add both a CLI output to the console and create a results.sarif file |
| 38 | + output_format: cli,sarif |
| 39 | + output_file_path: console,results.sarif |
| 40 | + |
| 41 | + - name: Upload SARIF file |
| 42 | + uses: github/codeql-action/upload-sarif@v3 |
| 43 | + |
| 44 | + # Results are generated only on a success or failure |
| 45 | + # this is required since GitHub by default won't run the next step |
| 46 | + # when the previous one has failed. Security checks that do not pass will 'fail'. |
| 47 | + # An alternative is to add `continue-on-error: true` to the previous step |
| 48 | + # Or 'soft_fail: true' to checkov. |
| 49 | + if: success() || failure() |
| 50 | + with: |
| 51 | + sarif_file: results.sarif |
0 commit comments