加速离线安装包重复构建 #89
This file contains hidden or 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
| name: Security | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "41 20 * * 3" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| security-events: write | |
| jobs: | |
| gitleaks: | |
| name: gitleaks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Gitleaks | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| version="8.30.1" | |
| asset="gitleaks_${version}_linux_x64.tar.gz" | |
| base_url="https://github.com/gitleaks/gitleaks/releases/download/v${version}" | |
| tmp_dir="$(mktemp -d)" | |
| curl --fail --location --retry 3 --retry-delay 2 --output "$tmp_dir/$asset" "$base_url/$asset" | |
| curl --fail --location --retry 3 --retry-delay 2 --output "$tmp_dir/checksums.txt" "$base_url/gitleaks_${version}_checksums.txt" | |
| checksum_line="$(grep " ${asset}$" "$tmp_dir/checksums.txt")" | |
| printf '%s\n' "$checksum_line" | (cd "$tmp_dir" && sha256sum --check --strict) | |
| tar -xzf "$tmp_dir/$asset" -C "$tmp_dir" gitleaks | |
| echo "$tmp_dir" >> "$GITHUB_PATH" | |
| - name: Run Gitleaks | |
| run: gitleaks detect --source . --redact --no-banner --config .gitleaks.toml | |
| secrets-and-sbom: | |
| name: secrets-and-sbom | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Restore tools | |
| run: dotnet tool restore | |
| - name: Restore .NET packages | |
| run: dotnet restore CodexCliPlus.sln --locked-mode | |
| - name: Generate CycloneDX SBOM | |
| run: dotnet dotnet-CycloneDX CodexCliPlus.sln -o artifacts/sbom -fn codexcliplus.cyclonedx.xml | |
| - name: Generate Syft SBOM | |
| uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 | |
| with: | |
| path: . | |
| format: cyclonedx-json | |
| output-file: artifacts/sbom/codexcliplus.syft.cyclonedx.json | |
| - name: Upload SBOM artifacts | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: sbom | |
| path: artifacts/sbom |