Skip to content

Commit c43cf7e

Browse files
authored
Update Scorecard scanner workflow to latest version (#77)
Update the workflow to what we use in our other repos.
1 parent b32885f commit c43cf7e

2 files changed

Lines changed: 98 additions & 60 deletions

File tree

‎.github/workflows/ossf-scorecard.yaml‎

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Scorecard analysis
16+
run-name: Run Scorecard analyzer
17+
18+
# Scorecard (https://github.com/ossf/scorecard) is a repository-scanning tool
19+
# that evaluates a project's security practices. Its use is suggested by
20+
# Google's GitHub team. Scorecard's findings are reported in a repo's scanning
21+
# results page, https://github.com/quantumlib/REPO/security/code-scanning/.
22+
23+
on:
24+
schedule:
25+
# Run weekly on Saturdays.
26+
- cron: '30 9 * * 6'
27+
28+
pull_request:
29+
types:
30+
- opened
31+
- synchronize
32+
- reopened
33+
- ready_for_review
34+
branches:
35+
- main
36+
37+
workflow_dispatch:
38+
39+
concurrency:
40+
cancel-in-progress: true
41+
group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}}
42+
43+
permissions: {}
44+
45+
jobs:
46+
run-scorecard:
47+
# Skip fork PRs to avoid "Analysis configuration not found" errors.
48+
if: >-
49+
github.repository_owner == 'quantumlib' &&
50+
(github.event_name != 'pull_request' ||
51+
github.event.pull_request.head.repo.fork == false)
52+
name: Scorecard analyzer
53+
runs-on: ubuntu-24.04
54+
permissions:
55+
security-events: write
56+
id-token: write
57+
contents: read
58+
actions: read
59+
issues: read
60+
pull-requests: read
61+
checks: read
62+
timeout-minutes: 15
63+
steps:
64+
- name: Check out a copy of the git repository
65+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
66+
with:
67+
persist-credentials: false
68+
69+
- name: Run Scorecard analysis
70+
# yamllint disable rule:line-length
71+
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
72+
with:
73+
results_file: scorecard-results.sarif
74+
results_format: sarif
75+
publish_results: true
76+
77+
- name: Upload results to code-scanning dashboard
78+
# yamllint disable rule:line-length
79+
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
80+
with:
81+
sarif_file: scorecard-results.sarif
82+
83+
# Scorecard doesn't allow submissions from jobs having steps that use "run:".
84+
# Printing a summary needs to use "run:", so we have to use a separate job.
85+
write-summary:
86+
name: Scorecard results
87+
needs: run-scorecard
88+
runs-on: ubuntu-slim
89+
timeout-minutes: 5
90+
steps:
91+
- name: Write the Scorecard report page link to the workflow summary
92+
run: |
93+
repo="${{github.repository}}"
94+
url="https://scorecard.dev/viewer/?uri=github.com/${repo}"
95+
{
96+
echo -n "The results are available on the OpenSSF Scorecard "
97+
echo "[report page for ${{github.repository}}]($url)."
98+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)