From 0c7c5c134c3e65b4115c61add2298d4d79f23306 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 2 Dec 2026 22:26:41 +0000 Subject: [PATCH] fix(ci): split Pages build/deploy and tolerate a permission-limited Scorecard check --- .github/workflows/pages-deploy.yml | 19 +++++++++++++++---- .github/workflows/scorecard.yml | 8 ++++++-- docs/CI-en.html | 2 +- docs/CI.html | 2 +- test/ci/security-workflows-contract.test.js | 12 ++++++++++++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pages-deploy.yml b/.github/workflows/pages-deploy.yml index 6c52137b..835fdac2 100644 --- a/.github/workflows/pages-deploy.yml +++ b/.github/workflows/pages-deploy.yml @@ -32,8 +32,23 @@ concurrency: cancel-in-progress: false jobs: + build: + name: Build docs artifact + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ inputs.ref || github.ref }} + fetch-depth: 1 + persist-credentials: false + - uses: actions/configure-pages@v5 + - uses: actions/upload-pages-artifact@v3 + with: + path: docs deploy: name: Deploy docs/ and smoke the live URL + needs: build runs-on: ubuntu-latest timeout-minutes: 10 environment: @@ -45,10 +60,6 @@ jobs: ref: ${{ inputs.ref || github.ref }} fetch-depth: 1 persist-credentials: false - - uses: actions/configure-pages@v5 - - uses: actions/upload-pages-artifact@v3 - with: - path: docs - id: deployment uses: actions/deploy-pages@v4 - name: Post-deploy smoke (live URL) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index e57fcedd..d47c82eb 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -33,6 +33,7 @@ jobs: fetch-depth: 1 persist-credentials: false - name: Install and run Scorecard (pinned, checksum-verified) + continue-on-error: true env: GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -44,6 +45,9 @@ jobs: (cd /tmp && grep "scorecard_${VERSION}_linux_amd64.tar.gz" scorecard_checksums.txt | sha256sum -c -) tar -xzf "/tmp/scorecard_${VERSION}_linux_amd64.tar.gz" -C /tmp scorecard /tmp/scorecard --repo="github.com/$GITHUB_REPOSITORY" --format json --output scorecard.json --show-details - - name: Print the Scorecard result + - name: Validate and print the Scorecard result if: always() - run: cat scorecard.json || true + run: | + test -s scorecard.json + node -e "const r=require('./scorecard.json'); if (!Array.isArray(r.checks) || r.checks.length === 0) process.exit(1); console.log('SCORECARD score='+r.score+' checks='+r.checks.length);" + cat scorecard.json diff --git a/docs/CI-en.html b/docs/CI-en.html index b0fe7465..05c5121b 100644 --- a/docs/CI-en.html +++ b/docs/CI-en.html @@ -44,7 +44,7 @@
JobRunnerTimeout (min)StepsGuardsArtifactsSummaries
Deep sweep (node 24)ubuntu-latest457001

Pages Deploy pages-deploy.yml

Triggers: push · workflow_dispatch · Permissions: contents, pages, id-token · Concurrency: no cancel

-
JobRunnerTimeout (min)StepsGuardsArtifactsSummaries
Deploy docs/ and smoke the live URLubuntu-latest106001
+
JobRunnerTimeout (min)StepsGuardsArtifactsSummaries
Build docs artifactubuntu-latest103000
Deploy docs/ and smoke the live URLubuntu-latest104001

npm release (gated) release.yml

Triggers: push · workflow_dispatch · Permissions: contents, id-token · Concurrency: no cancel

JobRunnerTimeout (min)StepsGuardsArtifactsSummaries
publishubuntu-latest3012000
diff --git a/docs/CI.html b/docs/CI.html index 3ebd2f9a..34483606 100644 --- a/docs/CI.html +++ b/docs/CI.html @@ -44,7 +44,7 @@
الوظيفةالمنفّذالمهلة (دقيقة)الخطواتالحراسالقطع الأثريةملخصات
Deep sweep (node 24)ubuntu-latest457001

Pages Deploy pages-deploy.yml

المشغلات: push · workflow_dispatch · الصلاحيات: contents, pages, id-token · التزامن: no cancel

-
الوظيفةالمنفّذالمهلة (دقيقة)الخطواتالحراسالقطع الأثريةملخصات
Deploy docs/ and smoke the live URLubuntu-latest106001
+
الوظيفةالمنفّذالمهلة (دقيقة)الخطواتالحراسالقطع الأثريةملخصات
Build docs artifactubuntu-latest103000
Deploy docs/ and smoke the live URLubuntu-latest104001

npm release (gated) release.yml

المشغلات: push · workflow_dispatch · الصلاحيات: contents, id-token · التزامن: no cancel

الوظيفةالمنفّذالمهلة (دقيقة)الخطواتالحراسالقطع الأثريةملخصات
publishubuntu-latest3012000
diff --git a/test/ci/security-workflows-contract.test.js b/test/ci/security-workflows-contract.test.js index 0870b615..ffb6570f 100644 --- a/test/ci/security-workflows-contract.test.js +++ b/test/ci/security-workflows-contract.test.js @@ -39,6 +39,10 @@ export function validateSecurity({ codeql, dependencyReview, scorecard }) { if (!scorecardText.includes("scorecard_checksums.txt")) errors.push("scorecard: checksum file missing"); if (!scorecardText.includes("--format json")) errors.push("scorecard: JSON format missing"); if (!uses(scorecard).some((u) => /^actions\/checkout@v\d+$/.test(u))) errors.push("scorecard: checkout step missing"); + const scorecardRun = scorecard?.jobs?.analysis?.steps?.find((st) => String(st.run || "").includes("--format json")); + if (scorecardRun?.["continue-on-error"] !== true) errors.push("scorecard: analysis must tolerate a permission-limited check"); + const scorecardValidate = scorecard?.jobs?.analysis?.steps?.find((st) => String(st.run || "").includes("test -s scorecard.json")); + if (!scorecardValidate) errors.push("scorecard: JSON validation step missing"); return errors; } @@ -64,6 +68,14 @@ test("security workflows: negative controls bite", () => { const runStep = d.jobs.analysis.steps.find((st) => String(st.run || "").includes("--format json")); runStep.run = runStep.run.replace("--format json", ""); assert.ok(validateSecurity({ codeql, dependencyReview, scorecard: d }).some((e) => /JSON format/.test(e))); + d = clone(scorecard); + const co = d.jobs.analysis.steps.find((st) => String(st.run || "").includes("--format json")); + delete co["continue-on-error"]; + assert.ok(validateSecurity({ codeql, dependencyReview, scorecard: d }).some((e) => /tolerate/.test(e))); + d = clone(scorecard); + const val = d.jobs.analysis.steps.find((st) => String(st.run || "").includes("test -s scorecard.json")); + val.run = val.run.replace("test -s scorecard.json", ""); + assert.ok(validateSecurity({ codeql, dependencyReview, scorecard: d }).some((e) => /JSON validation/.test(e))); d = clone(dependencyReview); const actionStep = d.jobs.review.steps.find((st) => String(st.uses || "").startsWith("actions/dependency-review-action")); actionStep.uses = "actions/dependency-review-action@v4";