build: use multiScm for Kokoro release builds (#390) #377
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2023 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: OSSF Scorecard | |
on: | |
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection | |
branch_protection_rule: | |
schedule: | |
# weekly on Sunday | |
- cron: '0 20 * * 0' | |
push: | |
branches: [ "main" ] | |
# Declare default permissions as read only. | |
permissions: read-all | |
jobs: | |
analysis: | |
name: Scorecard analysis | |
runs-on: ubuntu-latest | |
permissions: | |
# Needed to upload the results to code-scanning dashboard. | |
security-events: write | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
- name: "Run analysis" | |
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 | |
with: | |
results_file: results.sarif | |
results_format: sarif | |
- name: Filter SARIF to skip false positives | |
# filter out DangerousWorkflow alerts as they do not account for safe use of labels to trigger actions | |
env: | |
SCORECARD_SKIPPED_RULE_IDS: "DangerousWorkflowID" | |
run: | | |
SCORECARD_SKIPPED_RULE_IDS_JSON=$(echo $SCORECARD_SKIPPED_RULE_IDS | jq -cR 'split(",")') | |
# Trim the SARIF file to remove false positive detections | |
cat results.sarif | jq '.runs[].results |= map(select(.ruleId as $id | '$SCORECARD_SKIPPED_RULE_IDS_JSON' | all($id != .)))' > resultsFiltered.sarif | |
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF | |
# format to the repository Actions tab. | |
- name: "Upload artifact" | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: SARIF file | |
path: results.sarif | |
retention-days: 5 | |
# Upload the results to GitHub's code scanning dashboard. | |
- name: "Upload to code-scanning" | |
uses: github/codeql-action/upload-sarif@396bb3e45325a47dd9ef434068033c6d5bb0d11a # v3.27.3 | |
with: | |
sarif_file: resultsFiltered.sarif |