CICD-180 · Check out code with read-only permissions
Encyclopedia · Workflow security fundamentals · All snippets
Previous · CICD-179 · Next · CICD-181
1. Where it fits
- Placement .github/workflows/ci.yml, inside the relevant job.
- Prerequisites trusted repository, verified inputs and read-only default access.
- Platforms github-actions, gitea-actions.
2. Copy the snippet
yaml
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false3. How it works
These permissions limit the job token. An external service credential has its own access policy.
4. Verify the result
Do not retain Git credentials when no Git push is needed.
Validation syntax-validated (YAML parse). Status definitions.