Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(ci): gate dispatch-from-branch on secret-bearing workflows (CHOO-1251, H4) (#119)

Louis Amaudruz9cd51f2de59f
diff --git a/.github/workflows/container_security.yml b/.github/workflows/container_security.yml
index 38f482ab7..c76d67fb9 100644
--- a/.github/workflows/container_security.yml
+++ b/.github/workflows/container_security.yml
@@ -36,8 +36,10 @@ permissions:
jobs:
scan-all:
- # Scheduled / manual full sweep -> standing VULNMGMT tickets.
- if: ${{ github.event_name != 'pull_request' }}
+ # Scheduled full sweep -> standing VULNMGMT tickets, or a manual dispatch
+ # from main. A workflow_dispatch from an arbitrary branch is skipped so the
+ # Jira machine-user token can't be exercised from unreviewed branch code.
+ if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }}
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml
index 3f8d5f41c..7f3262786 100644
--- a/.github/workflows/renovate.yml
+++ b/.github/workflows/renovate.yml
@@ -32,6 +32,10 @@ jobs:
renovate:
runs-on: ubuntu-latest
timeout-minutes: 60
+ # Runs on the weekly schedule (always on the default branch) or a manual
+ # dispatch from main. A workflow_dispatch from an arbitrary branch is skipped
+ # so the PR-bot App credentials can't be exercised from unreviewed branch code.
+ if: ${{ github.event_name == 'schedule' || github.ref == 'refs/heads/main' }}
env:
# Gate the App-token step without referencing a missing secret in an `if:`.
BOT_CLIENT_ID: ${{ secrets.AUTOFIX_PR_BOT_CLIENT_ID }}
diff --git a/.github/workflows/socket_cve_fix.yml b/.github/workflows/socket_cve_fix.yml
index 24ac2e17f..f915eb32d 100644
--- a/.github/workflows/socket_cve_fix.yml
+++ b/.github/workflows/socket_cve_fix.yml
@@ -14,6 +14,11 @@ permissions:
jobs:
socket-fix:
runs-on: ubuntu-latest
+ # Runs on the monthly/weekly schedule (always on the default branch) or a
+ # manual dispatch from main. A workflow_dispatch from an arbitrary branch is
+ # skipped so the Socket key and PR-bot App credentials can't be exercised
+ # from unreviewed branch code.
+ if: ${{ github.event_name == 'schedule' || github.ref == 'refs/heads/main' }}
steps:
- name: Checkout repo
diff --git a/.github/workflows/switch-agent-runtime-publish.yml b/.github/workflows/switch-agent-runtime-publish.yml
index 350f35f13..ec06bc6b2 100644
--- a/.github/workflows/switch-agent-runtime-publish.yml
+++ b/.github/workflows/switch-agent-runtime-publish.yml
@@ -39,6 +39,11 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
+ # Publish only from a matching tag or from main. A workflow_dispatch from an
+ # arbitrary branch would otherwise publish whatever that branch's
+ # package.json says into the real @sandbox-quantum namespace, bypassing the
+ # tag-vs-version guard below (which only runs on the tag path).
+ if: ${{ startsWith(github.ref, 'refs/tags/switch-agent-runtime-v') || github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: write
diff --git a/.github/workflows/switchdash-release.yml b/.github/workflows/switchdash-release.yml
index 0823ef459..30904bf37 100644
--- a/.github/workflows/switchdash-release.yml
+++ b/.github/workflows/switchdash-release.yml
@@ -74,9 +74,15 @@ jobs:
build-macos:
name: Build & release (macOS arm64)
runs-on: macos-14
- # Runs on dispatch too, where create-release is skipped rather than run.
+ # The Apple Developer ID signing secrets live in the `release` environment
+ # (required reviewers + branch policy), so a run must be approved and can
+ # only come from main or a tag — a workflow_dispatch from an arbitrary
+ # branch cannot reach the org signing identity.
+ environment: release
+ # Runs on dispatch too (from main), where create-release is skipped rather
+ # than run. Restricted to main / tags so a feature-branch dispatch is skipped.
needs: create-release
- if: ${{ !cancelled() && needs.create-release.result != 'failure' }}
+ if: ${{ !cancelled() && needs.create-release.result != 'failure' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }}
# Surface the cert/key secrets through env so step-level `if:` can gate on
# them — the `secrets` context is not allowed in `if:` expressions.
env: