Repository navigation
81 lines (73 loc) · 2.97 KB
/
Copy pathscorecard.yaml
File metadata and controls
81 lines (73 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# OpenSSF Scorecard, from the official starter workflow:
# https://github.com/ossf/scorecard-action#workflow-setup
name: Scorecard supply-chain security
on:
# For the Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To keep the Maintained check up to date. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: "23 5 * * 1"
push:
branches: [main]
workflow_dispatch:
permissions: {}
jobs:
# Scheduled events carry no repository in their payload, so ask the API.
visibility:
name: Repository visibility
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
public: ${{ steps.repo.outputs.public }}
steps:
- uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit
- id: repo
env:
GH_TOKEN: ${{ github.token }}
run: |
visibility=$(gh api "repos/${GITHUB_REPOSITORY}" --jq .visibility)
echo "public=$([[ "$visibility" == public ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
if [[ "$visibility" != public ]]; then
echo "::notice::The repository is ${visibility}: Scorecard runs once it's public."
fi
analysis:
name: Scorecard analysis
needs: visibility
# Scorecard on a private repository needs GitHub Advanced Security and
# can't publish results.
if: needs.visibility.outputs.public == 'true'
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to the code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
steps:
- uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run analysis
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
with:
results_file: results.sarif
results_format: sarif
# (Optional) A "read" PAT enables the Branch-Protection check:
# https://github.com/ossf/scorecard-action#authentication-with-fine-grained-pat-optional
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Publish the results to the OpenSSF REST API, which the Scorecard
# badge reads: https://github.com/ossf/scorecard-action#publishing-results
publish_results: true
# Upload the results to GitHub's code scanning dashboard.
- name: Upload to code scanning
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
with:
sarif_file: results.sarif