|
1 | | -# scorecard-actions |
2 | | -This repository contains the code for [scorecard](https://github.com/ossf/scorecard)'s GitHub actions. |
| 1 | +# Scorecards' GitHub action |
| 2 | + |
| 3 | +> Official GitHub Action for [OSSF scorecard](https://github.com/ossf/scorecard). |
| 4 | +
|
| 5 | +## Installation |
| 6 | +The simplest and quickest way to install Scorecards's GitHub action is from the [GitHub's marketplace](https://github.com/marketplace/actions/ossf-scorecard-action). |
| 7 | + |
| 8 | +### Inputs |
| 9 | + |
| 10 | +| Name | Required | Description | |
| 11 | +| ----- | -------- | ----------- | |
| 12 | +| `result_file` | yes | The file that contains the results. | |
| 13 | +| `result_format` | yes | The format in which to store the results [json \| sarif]. For GitHub's scanning dashboard, select `sarif`. | |
| 14 | +| `repo_token` | yes | PAT token with read-only access. Follow [these steps](#pat-token-creation) to create it. | |
| 15 | +| `publish_results` | recommended | This will allow you to display a badge on your repository to show off your hard work (release scheduled for Q2'22). See details [here](#publishing-results).| |
| 16 | + |
| 17 | +### PAT token creation |
| 18 | +1. Create a PAT token [here](https://github.com/settings/tokens/new) with the following read permissions: |
| 19 | + - Note: `Read-only token for OSSF Scorecard Action` |
| 20 | + - Expiration: `No expiration` |
| 21 | + - Scopes: |
| 22 | + * `repo > public_repo` |
| 23 | + * `admin:org > read:org` |
| 24 | + * `admin:repo_hook > read:repo_hook` |
| 25 | + * `write:discussion > read:discussion` |
| 26 | + - Create and copy the token. |
| 27 | + |
| 28 | +2. Create a new repository secret at `https://github.com/<org>/<repo>/settings/secrets/actions/new` with the following settings: |
| 29 | + - Name: `SCORECARD_TOKEN` |
| 30 | + - Value: the value of the token created in step 1 above. |
| 31 | + |
| 32 | +### Publishing results |
| 33 | +The Scorecard team runs a weekly scan of public GitHub repositories in order to track |
| 34 | +the overall security health of the open source ecosystem. The results of the scans are publicly |
| 35 | +available as described [here](https://github.com/ossf/scorecard#public-data). |
| 36 | +Setting `publish_results: true` replaces the results of the team's weelky scans, |
| 37 | +helping us scale by cutting down on repeated workflows and GitHub API requests. |
| 38 | +This option is needed to enable badges on the repo (release scheduled for Q2'22). |
| 39 | +If you are installing the action on a private repo, set it to `publish_results: false` or |
| 40 | +comment the line. |
| 41 | + |
| 42 | +### Full example |
| 43 | + |
| 44 | +```yml |
| 45 | +name: Scorecards supply-chain security |
| 46 | +on: |
| 47 | + # Only the default branch is supported. |
| 48 | + branch_protection_rule: |
| 49 | + schedule: |
| 50 | + # Weekly on Saturdays. |
| 51 | + - cron: '30 1 * * 6' |
| 52 | + push: |
| 53 | + branches: [ main, master ] |
| 54 | + |
| 55 | +# Declare default permissions as read only. |
| 56 | +permissions: read-all |
| 57 | + |
| 58 | +jobs: |
| 59 | + analysis: |
| 60 | + name: Scorecards analysis |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + # Needed to upload the results to code-scanning dashboard. |
| 64 | + security-events: write |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: "Checkout code" |
| 68 | + uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 |
| 69 | + with: |
| 70 | + persist-credentials: false |
| 71 | + |
| 72 | + - name: "Run analysis" |
| 73 | + uses: ossf/scorecard-action@59f9117686133e93b60a8f23131f87089a076e1b |
| 74 | + with: |
| 75 | + results_file: results.sarif |
| 76 | + results_format: sarif |
| 77 | + # Read-only PAT token. To create it, |
| 78 | + # follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation. |
| 79 | + repo_token: ${{ secrets.SCORECARD_TOKEN }} |
| 80 | + # Publish the results to enable scorecard badges. For more details, see |
| 81 | + # https://github.com/ossf/scorecard-action#publishing-results. |
| 82 | + # If you are installing the action on a private repo, set it to `publish_results: false` |
| 83 | + # or comment out the following line. |
| 84 | + publish_results: true |
| 85 | + |
| 86 | + # Upload the results as artifacts (optional). |
| 87 | + - name: "Upload artifact" |
| 88 | + uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1 |
| 89 | + with: |
| 90 | + name: SARIF file |
| 91 | + path: results.sarif |
| 92 | + retention-days: 5 |
| 93 | + |
| 94 | + # Upload the results to GitHub's code scanning dashboard. |
| 95 | + - name: "Upload to code-scanning" |
| 96 | + uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26 |
| 97 | + with: |
| 98 | + sarif_file: results.sarif |
| 99 | +``` |
0 commit comments