Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/discord-posts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
sudo apt-get update
sudo apt-get install -y gh

# TODO: Perhaps we should merge this into the public-pr-merge.yml workflow, now that that exists.
- name: Send Discord notification
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
Expand Down Expand Up @@ -69,3 +70,22 @@
# Use `jq` to construct the json data blob in the format required by the webhook.
data="$(jq --null-input --arg msg "$message" '.content=$msg')"
curl -X POST -H 'Content-Type: application/json' -d "$data" "${DISCORD_WEBHOOK_URL}"

invokePrivate:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before merging:

Suggested change
if: github.event.pull_request.merged == true
if: github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'master'

steps:
- name: Dispatch private merge workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.SPACETIMEDB_PRIVATE_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'clockworklabs',
repo: 'SpacetimeDBPrivate',
workflow_id: 'public-pr-merge.yml',
ref: 'bfops/smarter-internal-tests',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before merging:

Suggested change
ref: 'bfops/smarter-internal-tests',
ref: 'master',

inputs: {
public_pr_number: String(context.payload.pull_request.number),
}
});
Comment on lines +75 to +91

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 1 day ago

In general, the fix is to add an explicit permissions: block either at the workflow root (to apply to all jobs) or per job, granting only the scopes the workflow needs. Since this workflow appears to only need read access to repository contents and PR metadata via GITHUB_TOKEN, it can safely use contents: read at the workflow level as a minimal baseline. If in the future a job requires additional permissions, they can be added on that specific job.

The single best change here is: add a workflow-level permissions: block near the top of .github/workflows/discord-posts.yml, directly under the on: section, specifying contents: read. This will apply to both discordNotification and invokePrivate jobs. The invokePrivate job doesn’t use GITHUB_TOKEN at all (it uses secrets.SPACETIMEDB_PRIVATE_TOKEN), so it does not need additional permissions. No other functionality needs to change, and no imports or external libraries are required, since this is purely GitHub Actions YAML configuration.

Concretely:

  • Edit .github/workflows/discord-posts.yml.
  • After the on: ... block (lines 3–5), insert:
    permissions:
      contents: read
  • Leave the rest of the workflow unchanged. This explicitly limits the GITHUB_TOKEN to read-only access to repository contents and associated metadata, which is sufficient for running gh pr checks and other read-only operations in this workflow.
Suggested changeset 1
.github/workflows/discord-posts.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/discord-posts.yml b/.github/workflows/discord-posts.yml
--- a/.github/workflows/discord-posts.yml
+++ b/.github/workflows/discord-posts.yml
@@ -4,6 +4,9 @@
   pull_request:
     types: [closed]
 
+permissions:
+  contents: read
+
 jobs:
   discordNotification:
     runs-on: ubuntu-latest
EOF
@@ -4,6 +4,9 @@
pull_request:
types: [closed]

permissions:
contents: read

jobs:
discordNotification:
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
Loading