Git & GitHub Interview Question #103

What are permissions in GitHub Actions?

Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced

Quick Interview Answer

Workflow permissions control what the automatically provided GitHub token can do. Permissions can be set at workflow or job level for capabilities such as reading repository contents or writing certain repository resources.

Detailed Explanation

Workflow permissions control what the automatically provided GitHub token can do. Permissions can be set at workflow or job level for capabilities such as reading repository contents or writing certain repository resources.

A secure workflow should grant only the permissions it actually needs. Explicit least-privilege permissions reduce the impact of a compromised action or workflow step.

Code Example

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: dotnet build