Skip to content

Apply least-privilege permissions to GitHub Actions workflow - #7

Merged
Sakura-Ex merged 2 commits into
feat/test-workflowfrom
copilot/sub-pr-6
Feb 7, 2026
Merged

Apply least-privilege permissions to GitHub Actions workflow#7
Sakura-Ex merged 2 commits into
feat/test-workflowfrom
copilot/sub-pr-6

Conversation

Copilot AI commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Addresses security feedback to restrict workflow permissions following the principle of least privilege.

Changes

  • Set workflow-level permissions to contents: read (default for all jobs)
  • Override with contents: write at job-level for release job only

This ensures test and build jobs run with read-only access, while only release retains write permissions needed for creating GitHub releases.

# Workflow level - default for all jobs
permissions:
  contents: read

jobs:
  release:
    # Job level - override only where needed
    permissions:
      contents: write

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Sakura-Ex <49809606+Sakura-Ex@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate CI/CD pipeline and release workflow Apply least-privilege permissions to GitHub Actions workflow Feb 7, 2026
Copilot AI requested a review from Sakura-Ex February 7, 2026 12:39
@Sakura-Ex
Sakura-Ex marked this pull request as ready for review February 7, 2026 12:39
Copilot AI review requested due to automatic review settings February 7, 2026 12:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens the GitHub Actions workflow token permissions to follow least-privilege by defaulting to read-only repository contents access and elevating permissions only for the release job.

Changes:

  • Set workflow-level permissions to contents: read
  • Add job-level override permissions: contents: write for the release job

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 25 to 27
permissions:
contents: write
contents: read

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

Setting workflow-level permissions to only contents: read implicitly sets all other GITHUB_TOKEN permissions to none. This workflow uses actions/cache@v4 and actions/upload-artifact@v4 / actions/download-artifact@v4, which require actions: write (cache save/upload) and at least actions: read (download). As-is, the test/build/release jobs may start failing with permission errors. Add the minimal required actions: permission at workflow level and/or per job (e.g., grant actions: write to jobs that save cache/upload artifacts, and actions: read to jobs that only download).

Copilot uses AI. Check for mistakes.
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write

Copilot AI Feb 7, 2026

Copy link

Choose a reason for hiding this comment

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

The release job overrides contents: write but still inherits actions: none from the workflow-level permissions. Since this job uses actions/download-artifact@v4, it needs actions: read (or actions: write) to fetch artifacts; otherwise the download step can fail. Add actions: read to the release job's permissions block (and keep contents: write).

Suggested change
contents: write
contents: write
actions: read

Copilot uses AI. Check for mistakes.
@Sakura-Ex
Sakura-Ex merged commit badb7e5 into feat/test-workflow Feb 7, 2026
6 checks passed
@Sakura-Ex
Sakura-Ex deleted the copilot/sub-pr-6 branch February 7, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants