- ci: add minimum required permissions to GitHub Actions workflows#159
Merged
- ci: add minimum required permissions to GitHub Actions workflows#159
Conversation
Co-authored-by: mtracz <22484267+mtracz@users.noreply.github.com> Agent-Logs-Url: https://github.com/blumilksoftware/lmt/sessions/2cdd6ca5-483e-4170-bea5-508f673b41f0
Copilot
AI
changed the title
[WIP] Audit and fix GitHub Actions workflows by adding permissions
ci: add minimum required permissions to GitHub Actions workflows
Mar 25, 2026
EwelinaSkrzypacz
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All four workflows were missing explicit
permissionsblocks, leaving them with GitHub's overly-permissive defaults. This adds least-privilege permissions at the top level of each workflow.Changes
check-php.yml—contents: read(PR lint/test, read-only)title.yml—contents: read+pull-requests: read(needs PR metadata for title check)deploy-to-dev.yml—contents: read(SSH deploy to external registry, no GITHUB_TOKEN writes)deploy-to-production.yml—contents: read(same as dev)Original prompt
Goal
Audit and fix all GitHub Actions workflows in
.github/workflows/by adding explicitpermissionsblocks with the minimum required permissions. This follows the security best practice of least-privilege (principle of minimal permissions). Also fix any other security issues found.Security principles to apply
permissions: read-allat the top-level as a global default deny-all (or better:permissions: {}which sets everything tonone), then grant only what each job truly needs.permissionsblocks with only what that job needs.write-allon private repos, or broad on public repos without top-level restriction).GITHUB_TOKENwrite permissions unless strictly required.Workflows to fix
.github/workflows/check-php.ymlpull_requestonly — reads code, runs tests/lint, no writes needed..github/workflows/title.ymlpull_request— checks PR title usingblumilksoftware/action-pr-title.pull-requests: read..github/workflows/deploy-to-dev.ymlworkflow_dispatch— deploys via SSH, builds/pushes Docker images to an external registry (not GHCR), fetches secrets from Infisical. No GITHUB_TOKEN write needed..github/workflows/deploy-to-production.ymlworkflow_dispatchwith tag input — same pattern as deploy-to-dev.Current file contents for reference
check-php.yml (BlobSha: 4603c26a3800a3013b3d51f03e95b837289574d8)
title.yml (BlobSha: 788b29aca177ca3463ac52fd807a091fa879494e)
deploy-to-dev.yml (BlobSha: 9acba3d4e5ea8e68f613c33774318091eff3442c)
Current content is 169 lines, deploying to dev via SSH. No GITHUB_TOKEN writes needed. Add
permissions: contents: readat top level.deploy-to-production.yml (BlobSha: 5ee9d1568d6d9a757f6cca896344e9f8f2191c9d)
Current content is 166 lines, deploying to production via SSH. No GITHUB_TOKEN writes needed. Add
permissions: contents: readat top level.Instructions
permissionsblock right after theon:block and beforejobs:(or at top level beforejobs:...This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.