Skip to content
Merged
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
16 changes: 16 additions & 0 deletions .github/workflows/code-discord-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release PostHog Code to Discord

on:
release:
types: [published]

# No GITHUB_TOKEN permissions needed -- only calls an external webhook
permissions: {}

jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: SethCohen/github-releases-to-discord@37afa88c8c9302a9307244b5a0d4e782d528a4b5 # v1.15.1
with:
webhook_url: ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
Comment on lines +12 to +16

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 about 7 hours ago

In general, the fix is to explicitly declare permissions for the workflow/job so that the GITHUB_TOKEN has the least privilege required. Since this workflow only posts to Discord using a secret and does not need to modify repository contents, a minimal permissions block granting contents: read (or even permissions: {} if no GitHub API access is needed) is appropriate.

The best minimally invasive fix is to add a permissions block to the notify job in .github/workflows/code-discord-release.yml. Place it under runs-on: ubuntu-latest and above steps:. To keep functionality unchanged but explicit, set contents: read, which is sufficient for most actions that might need to read basic repository metadata yet prevents unintended write operations. No imports or additional methods are needed; this is purely a YAML configuration change within the existing workflow.

Suggested changeset 1
.github/workflows/code-discord-release.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/code-discord-release.yml b/.github/workflows/code-discord-release.yml
--- a/.github/workflows/code-discord-release.yml
+++ b/.github/workflows/code-discord-release.yml
@@ -7,6 +7,8 @@
 jobs:
   notify:
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
     steps:
       - uses: SethCohen/github-releases-to-discord@v1.15.1
         with:
EOF
@@ -7,6 +7,8 @@
jobs:
notify:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: SethCohen/github-releases-to-discord@v1.15.1
with:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

crazy work, github bot

Loading