diff --git a/.github/workflows/githits-policy.yml b/.github/workflows/githits-policy.yml new file mode 100644 index 0000000..95c6763 --- /dev/null +++ b/.github/workflows/githits-policy.yml @@ -0,0 +1,74 @@ +name: GitHits dependency policy +on: + pull_request_target: + types: [opened, synchronize, reopened] +permissions: + contents: read +concurrency: + group: githits-policy-${{ github.event.pull_request.number }} + cancel-in-progress: true +jobs: + policy: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Select credential-backed policy checks + id: access + env: + PROVIDER_TOKEN: ${{ secrets.GITHITS_FLYSPACE_API_TOKEN }} + RETENTION_TOKEN: ${{ secrets.GITHITS_USAGE_TOKEN }} + run: | + if [ -n "$PROVIDER_TOKEN" ] && [ -n "$RETENTION_TOKEN" ]; then + echo 'enabled=true' >> "$GITHUB_OUTPUT" + else + echo 'enabled=false' >> "$GITHUB_OUTPUT" + echo '::warning::GitHits dependency policy not verified: provider/private-retention credentials pending' + echo 'Dependency policy coverage skipped: credentials pending. No clean security claim.' >> "$GITHUB_STEP_SUMMARY" + fi + # Only immutable source data is read from the proposed revision. No PR scripts run. + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + if: steps.access.outputs.enabled == 'true' + with: + ref: ${{ github.event.pull_request.base.sha }} + path: base + persist-credentials: false + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + if: steps.access.outputs.enabled == 'true' + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.sha }} + # Opt in only for data-only fork inspection by the trusted private runner. + allow-unsafe-pr-checkout: true + path: head + persist-credentials: false + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + if: steps.access.outputs.enabled == 'true' + with: + repository: SyberLabs/MasterMind + ref: bf0dd6c22b9411a82dfebb3a533c1fb8a1e7b2e8 + token: ${{ secrets.GITHITS_USAGE_TOKEN }} + path: .private-githits + persist-credentials: false + sparse-checkout: tools/githits-usage/** + sparse-checkout-cone-mode: false + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + if: steps.access.outputs.enabled == 'true' + with: + node-version: '24' + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + if: steps.access.outputs.enabled == 'true' + with: + python-version: '3.13' + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 + if: steps.access.outputs.enabled == 'true' + with: + version: 11.25.0 + - name: Install the pinned private runner without lifecycle scripts + if: steps.access.outputs.enabled == 'true' + run: pnpm --dir .private-githits/tools/githits-usage install --frozen-lockfile --ignore-scripts + - name: Review dependency changes through private accounting and cache + if: steps.access.outputs.enabled == 'true' + run: node .private-githits/tools/githits-usage/policy.mjs --repo "$GITHUB_REPOSITORY" --head "$GITHUB_WORKSPACE/head" --base "$GITHUB_WORKSPACE/base" + env: + GITHITS_API_TOKEN: ${{ secrets.GITHITS_FLYSPACE_API_TOKEN }} + GITHITS_USAGE_TOKEN: ${{ secrets.GITHITS_USAGE_TOKEN }}