ci: give every workflow an explicit least-privilege GITHUB_TOKEN (#23)

CodeQL actions/missing-workflow-permissions: auto-approve.yml, auto-merge.yml, lock.yml, pr-any.yml, push-master.yml had no permissions block, so their jobs received the repository default token. Read-only where nothing writes through GITHUB_TOKEN; lock-threads gets the issues/pull-requests/discussions write it documents; workflows that write do it with a separate bot or app token, so GITHUB_TOKEN stays read-only.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-10-20 23:00:29 +04:00
1 parent ef5d2fbff5
commit de9f5a8604
5 files changed
+27

No files matched your search

+5
View File
@@ -4,6 +4,11 @@ on:
pull_request:
types: [labeled]
# Writes go through a separate bot token or app token; GITHUB_TOKEN stays read-only.
permissions:
contents: read
jobs:
approve:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
+5
View File
@@ -4,6 +4,11 @@ on:
pull_request:
types: [labeled]
# Writes go through a separate bot token or app token; GITHUB_TOKEN stays read-only.
permissions:
contents: read
jobs:
merge:
runs-on: ubuntu-latest
+7
View File
@@ -4,6 +4,13 @@ on:
schedule:
- cron: '30 1/3 * * *'
# dessant/lock-threads locks closed issues, PRs and discussions.
permissions:
issues: write
pull-requests: write
discussions: write
jobs:
lock:
runs-on: ubuntu-latest
+5
View File
@@ -1,6 +1,11 @@
name: PR
on: [pull_request]
# Read-only token: no step writes through GITHUB_TOKEN.
permissions:
contents: read
jobs:
pr:
strategy:
+5
View File
@@ -4,6 +4,11 @@ on:
branches:
- master
# Writes go through a separate bot token or app token; GITHUB_TOKEN stays read-only.
permissions:
contents: read
jobs:
master:
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"