Fix GitHub Actions workflow permissions for private repositories#119
Closed
Fix GitHub Actions workflow permissions for private repositories#119
Conversation
|
|
Co-authored-by: Ninja3047 <1284324+Ninja3047@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] some workflows don't work with private repos
Fix GitHub Actions workflow permissions for private repositories
Sep 26, 2025
Ninja3047
requested changes
Sep 26, 2025
Contributor
Ninja3047
left a comment
There was a problem hiding this comment.
the permissions should be scoped per job if possible instead of globally
Ninja3047
requested changes
Sep 26, 2025
Comment on lines
+9
to
+10
| permissions: | ||
| contents: read # needed for checkout in private repos |
Contributor
There was a problem hiding this comment.
this doesn't need to be here
it should be only in the actions/checkout scope
@copilot
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.
Problem
GitHub Actions workflows in this cookiecutter template were failing when used with private repositories due to overly restrictive permissions. All workflows had
permissions: {}which prevents actions likecheckoutfrom accessing repository contents in private repos.Solution
Updated all workflow files to include the minimum required permissions for private repository access:
Changes
tests.ymlandzizmor.ymltests.yml,lint.yml,docs.yml,release.yml, andzizmor.ymlThe fix follows the principle of least privilege by only adding the
contents: readpermission required for thecheckoutaction to work in private repositories, while preserving existing job-level permissions where they were already properly configured.Testing
Verified that:
This change ensures workflows will function properly in both public and private repositories without compromising security.
Original prompt
💡 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.