Files
starter-workflows/code-scanning/scorecard.yml
T

79 lines
3.4 KiB
YAML
Raw Normal View History

2022-10-07 18:22:49 +00:00
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
2022-01-14 03:00:11 +00:00
on:
2022-10-07 14:25:58 +00:00
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
2021-12-10 17:49:59 +00:00
branch_protection_rule:
2022-10-07 14:25:58 +00:00
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
2021-12-10 17:49:59 +00:00
schedule:
2021-12-16 18:25:53 +00:00
- cron: $cron-weekly
2021-12-10 17:49:59 +00:00
push:
branches: [ $default-branch ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
2021-12-10 17:49:59 +00:00
runs-on: ubuntu-latest
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
2021-12-10 17:49:59 +00:00
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
2022-10-07 14:25:58 +00:00
# Needed to publish results and get a badge (see publish_results below).
2022-05-26 14:46:58 +00:00
id-token: write
2022-10-07 14:25:58 +00:00
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read
2022-09-23 18:04:56 -03:00
2021-12-10 17:49:59 +00:00
steps:
- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2021-12-28 17:49:56 +00:00
with:
persist-credentials: false
2021-12-10 17:49:59 +00:00
- name: "Run analysis"
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
2021-12-10 17:49:59 +00:00
with:
results_file: results.sarif
results_format: sarif
2022-11-22 19:23:58 +00:00
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
2022-05-26 14:46:58 +00:00
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
2022-11-22 19:23:58 +00:00
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
2022-05-26 14:46:58 +00:00
2022-10-07 14:25:58 +00:00
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
2022-10-10 15:48:40 +00:00
# For private repositories:
2022-10-07 14:25:58 +00:00
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
2021-12-10 17:49:59 +00:00
publish_results: true
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
# file_mode: git
2022-05-26 14:46:58 +00:00
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
2021-12-10 17:49:59 +00:00
- name: "Upload artifact"
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
2021-12-10 17:49:59 +00:00
with:
name: SARIF file
path: results.sarif
retention-days: 5
2022-09-23 18:04:56 -03:00
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
2021-12-10 17:49:59 +00:00
- name: "Upload to code-scanning"
2024-07-29 14:37:50 -04:00
uses: github/codeql-action/upload-sarif@v3
2021-12-10 17:49:59 +00:00
with:
sarif_file: results.sarif