|
| 1 | +# Use Snyk to find and fix vulnerabilities in your GitHub repository. |
| 2 | +# https://github.com/snyk/actions/ |
| 3 | + |
| 4 | +name: Snyk Security |
| 5 | + |
| 6 | +on: |
| 7 | + # Scan every Sunday at 1am |
| 8 | + schedule: |
| 9 | + - cron: '0 1 * * SUN' |
| 10 | + # Scan every push to main branch |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + # Scan every pull request to main branch |
| 15 | + pull_request: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + snyk: |
| 24 | + permissions: |
| 25 | + contents: read # for actions/checkout to fetch code |
| 26 | + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results |
| 27 | + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status |
| 28 | + |
| 29 | + runs-on: ubuntu-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout source |
| 33 | + uses: actions/checkout@v3 |
| 34 | + |
| 35 | + - name: Setup Node |
| 36 | + uses: actions/setup-node@v3 |
| 37 | + with: |
| 38 | + node-version-file: .nvmrc |
| 39 | + cache: yarn |
| 40 | + cache-dependency-path: yarn.lock |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: yarn install |
| 44 | + |
| 45 | + - name: Setup Snyk |
| 46 | + uses: snyk/actions/setup@master |
| 47 | + env: |
| 48 | + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} |
| 49 | + |
| 50 | + - name: Snyk Code Scan |
| 51 | + run: snyk code test --sarif > snyk-code.sarif |
| 52 | + continue-on-error: true # so that the SARIF upload gets called |
| 53 | + env: |
| 54 | + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} |
| 55 | + |
| 56 | + - name: Snyk Open Source Monitor |
| 57 | + run: snyk monitor --all-projects |
| 58 | + continue-on-error: true # so that the SARIF upload gets called |
| 59 | + env: |
| 60 | + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} |
| 61 | + |
| 62 | + - name: Upload results to GitHub Code Scanning |
| 63 | + uses: github/codeql-action/upload-sarif@v2 |
| 64 | + with: |
| 65 | + sarif_file: snyk-code.sarif |
| 66 | + category: Snyk |
0 commit comments