Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci: weekly Semgrep uploads SARIF to code scanning; publish-template skip is a visible warning

garrytan09b7162b48ea
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6ad6595316..c796227747 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -221,12 +221,22 @@ jobs:
- id: gate
name: Gate on PAT + vendored template tree
run: |
+ # A skip here is visible (warning + step summary), never a silent
+ # green: this release did not publish the agent template (D-10).
if [ -z "$TEMPLATE_REPO_PAT" ]; then
echo "publish=false" >> "$GITHUB_OUTPUT"
- echo "SKIP: TEMPLATE_REPO_PAT secret not configured — template-repo publishing disabled."
+ echo "::warning::Agent template NOT published to $TEMPLATE_REPO — the TEMPLATE_REPO_PAT secret is empty. Why: only the repo owner can set secrets. Fix (owner-only): gh secret set TEMPLATE_REPO_PAT (fine-grained PAT with contents: write on $TEMPLATE_REPO), then re-run this release workflow."
+ {
+ echo "## Agent template not published"
+ echo "The TEMPLATE_REPO_PAT secret is empty, so \`$TEMPLATE_REPO\` did not get this release's \`templates/bootstrap/template-repo/\` tree."
+ echo ""
+ echo "- Why: only the repo owner can set secrets."
+ echo "- Fix (owner-only): \`gh secret set TEMPLATE_REPO_PAT\` (fine-grained PAT, contents: write on \`$TEMPLATE_REPO\`), then re-run this workflow."
+ } >> "$GITHUB_STEP_SUMMARY"
elif [ ! -d templates/bootstrap/template-repo ]; then
echo "publish=false" >> "$GITHUB_OUTPUT"
- echo "SKIP: templates/bootstrap/template-repo/ not vendored yet — nothing to publish."
+ echo "::warning::Agent template NOT published — templates/bootstrap/template-repo/ is missing from this checkout. Fix: restore the vendored tree, then re-run this release workflow."
+ echo "## Agent template not published: templates/bootstrap/template-repo/ is missing" >> "$GITHUB_STEP_SUMMARY"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
fi
diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml
index cf4a4ad417..2fd6009da3 100644
--- a/.github/workflows/semgrep.yml
+++ b/.github/workflows/semgrep.yml
@@ -1,9 +1,13 @@
name: Semgrep
# Static analysis (SAST) with Semgrep Community Edition (#2272). Tokenless:
-# uses the public registry rulesets, needs zero secrets. Findings print in
-# the job log; no code-scanning/SARIF upload by design (keeps permissions
-# read-only, no security-events: write).
+# uses the public registry rulesets, needs zero secrets.
+# - Pull requests (job `semgrep`, read-only): fail only on findings new since
+# the merge base.
+# - Weekly schedule and dispatch (job `semgrep-full`): full-tree scan, report
+# only, uploaded as SARIF to code scanning (Security -> Code scanning), so
+# the findings land somewhere a reviewer reads them. Only this job holds
+# security-events: write.
on:
pull_request:
@@ -21,6 +25,7 @@ concurrency:
jobs:
semgrep:
+ if: github.event_name == 'pull_request'
runs-on: ubicloud-standard-4-ubuntu-2404
timeout-minutes: 20
container:
@@ -33,8 +38,7 @@ jobs:
fetch-depth: 0
# Graduated from advisory: on a PR, fail only on findings NEW since the PR
# base (semgrep --baseline-commit), so legacy findings never block an
- # unrelated PR and no full-tree triage is required. Scheduled/dispatch
- # runs have no PR base, so they do a full-tree report-only scan.
+ # unrelated PR and no full-tree triage is required.
- name: Semgrep scan
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
@@ -42,15 +46,31 @@ jobs:
# The container user differs from checkout's owner. Trust only this
# workspace so our merge-base lookup works before Semgrep starts.
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- if [ -n "$BASE_SHA" ]; then
- # Diff against the MERGE BASE, not the base-branch head captured at
- # event time: the checkout is the merge ref against current master,
- # so a finding master landed after the event would otherwise be
- # attributed to this PR. merge-base is the true common ancestor.
- BASELINE="$(git merge-base "$BASE_SHA" HEAD || echo "$BASE_SHA")"
- echo "PR scan — failing only on findings new since $BASELINE"
- semgrep scan --config p/default --config p/typescript --error --baseline-commit "$BASELINE"
- else
- echo "Full-tree scan (schedule/dispatch) — report-only"
- semgrep scan --config p/default --config p/typescript || true
- fi
+ # Diff against the MERGE BASE, not the base-branch head captured at
+ # event time: the checkout is the merge ref against current master,
+ # so a finding master landed after the event would otherwise be
+ # attributed to this PR. merge-base is the true common ancestor.
+ BASELINE="$(git merge-base "$BASE_SHA" HEAD || echo "$BASE_SHA")"
+ echo "PR scan — failing only on findings new since $BASELINE"
+ semgrep scan --config p/default --config p/typescript --error --baseline-commit "$BASELINE"
+
+ semgrep-full:
+ if: github.event_name != 'pull_request'
+ runs-on: ubicloud-standard-4-ubuntu-2404
+ timeout-minutes: 20
+ permissions:
+ contents: read
+ security-events: write
+ container:
+ image: semgrep/semgrep:1.170.0@sha256:c98f8829eea377274ee4b10656458b078b88232469b2ff913f091c2317347c9d
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - name: Semgrep full-tree scan (report-only, SARIF)
+ run: |
+ semgrep scan --config p/default --config p/typescript --sarif-output=semgrep.sarif || true
+ test -s semgrep.sarif || { echo "::error::semgrep wrote no SARIF. Why: the scan crashed before reporting. Fix: rerun with gh workflow run semgrep.yml and read the scan log above."; exit 1; }
+ - name: Upload SARIF to code scanning
+ uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
+ with:
+ sarif_file: semgrep.sarif
+ category: semgrep
diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.ts
index e82bbce78a..939fb84d10 100644
--- a/test/release-workflow.test.ts
+++ b/test/release-workflow.test.ts
@@ -183,3 +183,28 @@ Release summary line.
expect(run('0.42.67').code).not.toBe(0);
});
});
+
+describe('release.yml publish-template skip is visible (D-10)', () => {
+ test('an empty TEMPLATE_REPO_PAT warns with the owner-only fix and writes a step summary', async () => {
+ const { safeLoad } = await import('js-yaml');
+ const wf = safeLoad(WORKFLOW) as { jobs: Record<string, { steps: Array<{ id?: string; run?: string }> }> };
+ const gate = wf.jobs['publish-template']!.steps.find(s => s.id === 'gate')!.run!;
+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-publish-template-gate-'));
+ try {
+ const output = join(dir, 'output');
+ const summary = join(dir, 'summary');
+ writeFileSync(output, '');
+ const stdout = execFileSync('bash', ['-euo', 'pipefail', '-c', gate], {
+ cwd: ROOT, encoding: 'utf8',
+ env: { PATH: process.env.PATH, TEMPLATE_REPO_PAT: '', TEMPLATE_REPO: 'owner/template-example', GITHUB_OUTPUT: output, GITHUB_STEP_SUMMARY: summary },
+ });
+ expect(readFileSync(output, 'utf8')).toContain('publish=false');
+ expect(stdout).toContain('::warning::Agent template NOT published to owner/template-example');
+ expect(stdout).toContain('Fix (owner-only): gh secret set TEMPLATE_REPO_PAT');
+ expect(readFileSync(summary, 'utf8')).toContain('## Agent template not published');
+ expect(stdout).not.toContain('SKIP:');
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+ });
+});