Skip to content

- ci: add minimum required permissions to GitHub Actions workflows#150

Open
Copilot wants to merge 2 commits intomainfrom
copilot/audit-github-actions-permissions
Open

- ci: add minimum required permissions to GitHub Actions workflows#150
Copilot wants to merge 2 commits intomainfrom
copilot/audit-github-actions-permissions

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Workflows were missing explicit permissions blocks, relying on GitHub's default token permissions which are overly permissive.

Changes

  • check-pr-title.yml — added contents: read + pull-requests: read (PR metadata access required by the title-check action)
  • check.yml — added contents: read (repo checkout only; no writes needed for lint/test)
# check-pr-title.yml
permissions:
  contents: read
  pull-requests: read

# check.yml
permissions:
  contents: read
Original prompt

Goal

Audit and fix all GitHub Actions workflows in .github/workflows/ by adding explicit permissions blocks with the minimum required permissions. This follows the security best practice of least-privilege (principle of minimal permissions).

Security principles to apply

  1. Add per-workflow permissions blocks with only what each workflow truly needs.
  2. Never leave workflows without explicit permissions — the default is overly permissive.
  3. Use pinned actions by SHA — all actions here are already pinned, keep them as-is.

Workflows to fix

.github/workflows/check-pr-title.yml (BlobSha: df68a2bf95734626ff9881d401ce93b69c5e9748)

  • Trigger: pull_request — checks PR title using blumilksoftware/action-pr-title. Needs to read PR metadata.
  • Add top-level permissions:
    permissions:
      contents: read
      pull-requests: read

.github/workflows/check.yml (BlobSha: 9cff3e8de7ff72266be809413c16a5c2f0c91aa5)

  • Trigger: push + pull_request — runs PHP linting and tests. No writes needed.
  • Add top-level permissions:
    permissions:
      contents: read

Current file contents

check-pr-title.yml

name: Check PR Title
on:
  pull_request:
    branches: [ "main" ]
    types: [opened, edited, synchronize, ready_for_review, reopened]

jobs:
  check-pr-title:
    name: Check PR title
    runs-on: ubuntu-24.04
    steps:
      - uses: blumilksoftware/action-pr-title@e05fc76a1cc45b33644f1de51218be43ac121dd0 # v1.2.0

check.yml

name: "Checking the package: testing and linting"

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    name: "Checking the package: testing and linting"
    runs-on: ubuntu-24.04

    strategy:
      matrix:
        php: ["8.3", "8.4"]

    steps:
      - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

      - name: Setup PHP
        uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
        with:
          php-version: ${{ matrix.php }}
          coverage: none

      - name: Cache composer dependencies
        uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
        with:
          path: vendor
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            ${{ runner.os }}-composer-

      - name: Validate composer.json
        run: composer validate

      - name: Install dependencies
        run: composer install --prefer-dist --no-progress

      - name: Run code style checker
        run: composer cs

      - name: Run tests
        run: composer test

Instructions

  • Edit both workflow files.
  • Add the permissions block after the on: block and before jobs:.
  • Do NOT change anything else in the files — no action version bumps, no logic changes, no formatting changes.
  • Create a single PR targeting the main branch.
  • PR title: ci: add minimum required permissions to GitHub Actions workflows
  • PR description should list each file changed with what permission was added and why.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Czy możesz wykonać pracę we wszystkich publicznych repozytoriach: https://github.com/orgs/blumilksoftware/repositories?q=visibility%3Apublic?

Czy możesz sam je zaznaczyć?

Assistant: Nie mogę “sam zaznaczyć”/wybrać wszystkich repozytoriów z tej strony ani wykonać zmian we wszystkich publicznych repozytoriach bez dwóch rzeczy:

  1. Konkretnie jaka praca ma być wykonana (co dokładnie mam zmienić / dodać / sprawdzić).
  2. Jednoznaczna lista repozytoriów (owner/repo) albo Twoje potwierdzenie, które repozytoria obejmujemy — bo nie mam tu dostępu do interfejsu GitHub, żeby “odklikać” je za Ciebie na tej stronie.

Żeby pójść dalej, wybierz proszę jedną z opcji:

Opcja A (najszybciej)

Wklej tutaj listę repozytoriów w formacie:

  • blumilksoftware/repo1
  • blumilksoftware/repo2

i opisz “pracę” (np. aktualizacja dependencji, dodanie pliku, zmiana workflow, itd.).

Opcja B (ja zbiorę listę repozytoriów)

Napisz: “Tak, zbierz listę” oraz doprecyzuj “pracę”. Wtedy ja pobiorę listę publicznych repozytoriów z GitHuba i pokażę Ci ją do zatwierdzenia (bo nadal musisz potwierdzić zakres).

Pytania doprecyzowujące (żeby od razu przygotować plan/zmiany)

  1. Co dokładnie mam zrobić w repozytoriach? (1–2 zdania wystarczą)
  2. Czy zmiany mają być przez:
    • PR-y do każdego repo (preferowane), czy
    • bezpośrednie commity (raczej odradzam)?
  3. Czy mam działać na domyślnej gałęzi (np. main/master), czy innej?

Jak odpowiesz na te 3 punkty, przygotuję dokładny plan, a potem wykonam pracę repo po repo (z PR-ami), ale potrzebuję od Ciebie listy albo zgody żebym ją najpierw zebrał.

User: Validate all github actions workflows and add/adjust workflow permissions to required minimum. Check each workflow. Create one pul...

This pull request was created from Copilot chat.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Audit and fix GitHub Actions workflows for explicit permissions ci: add minimum required permissions to GitHub Actions workflows Mar 25, 2026
Copilot AI requested a review from mtracz March 25, 2026 13:57
@mtracz mtracz changed the title ci: add minimum required permissions to GitHub Actions workflows - ci: add minimum required permissions to GitHub Actions workflows Mar 25, 2026
@mtracz mtracz marked this pull request as ready for review March 25, 2026 13:58
@mtracz mtracz requested a review from a team March 25, 2026 19:39
@mtracz mtracz requested a review from a team March 26, 2026 11: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