Skip to content

Commit ec1e737

Browse files
authored
Don't run Scorecard on fork PRs (#1269)
This simplifies the Scorecard scanner workflow by combining the conditions for running it and simply avoiding running the workflow on PRs from forks.
1 parent 2ee96f2 commit ec1e737

1 file changed

Lines changed: 11 additions & 26 deletions

File tree

.github/workflows/scorecard-scanner.yaml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# yamllint disable rule:line-length
16-
1715
name: Scorecard analysis
1816
run-name: Run Scorecard scanner for security best practices
1917

@@ -34,11 +32,6 @@ on:
3432

3533
# Allow manual invocation.
3634
workflow_dispatch:
37-
inputs:
38-
debug:
39-
description: 'Run with debugging options'
40-
type: boolean
41-
default: true
4235

4336
concurrency:
4437
# Cancel any previously-started but still active runs on the same branch.
@@ -50,7 +43,11 @@ permissions: read-all
5043

5144
jobs:
5245
run-scorecard:
53-
if: github.repository_owner == 'quantumlib'
46+
# Skip fork PRs to avoid "Analysis configuration not found" errors.
47+
if: >-
48+
github.repository_owner == 'quantumlib' &&
49+
(github.event_name != 'pull_request' ||
50+
github.event.pull_request.head.repo.fork == false)
5451
name: Scorecard analyzer
5552
runs-on: ubuntu-24.04
5653
permissions:
@@ -64,33 +61,21 @@ jobs:
6461
persist-credentials: false
6562

6663
- name: Run Scorecard analysis
64+
# yamllint disable rule:line-length
6765
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
6866
with:
69-
# Save the results
7067
results_file: scorecard-results.sarif
7168
results_format: sarif
72-
# Only publish results for non-fork PRs or scheduled runs.
73-
publish_results: >-
74-
${{github.event_name != 'pull_request'
75-
|| github.event.pull_request.head.repo.fork == false}}
69+
publish_results: true
7670

7771
- name: Upload results to code-scanning dashboard
78-
# Skip upload for fork PRs to avoid "Analysis configuration not found" / 404 errors.
79-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
80-
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
72+
# yamllint disable rule:line-length
73+
uses: github/codeql-action/upload-sarif@95e58e9a2cdfd71adc6e0353d5c52f41a045d225 # v4.35.2
8174
with:
8275
sarif_file: scorecard-results.sarif
8376

84-
- if: github.event.inputs.debug == true || runner.debug == true
85-
name: Upload results as artifacts to the workflow Summary page
86-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
87-
with:
88-
name: Scorecard SARIF file
89-
path: scorecard-results.sarif
90-
retention-days: 5
91-
92-
# Scorecard currently (ver. 2.4.x) doesn't allow submissions from jobs having
93-
# steps that use "run:". To print to the summary, we need to use another job.
77+
# Scorecard doesn't allow submissions from jobs having steps that use "run:".
78+
# Printing a summary needs to use "run:", so we have to use a separate job.
9479
write-summary:
9580
name: Scorecard results
9681
needs: run-scorecard

0 commit comments

Comments
 (0)