How do you give a job read access to a private repo that holds shared Terraform modules?
IntermediateScenarioGitHub Actions
Answer
Situation read → GITHUB_TOKEN is scoped to the current repo only.
What I'd do →
- Prefer a GitHub App: create an installation token with
actions/create-github-app-token@v1limited to the module repo. - Alternative: a read-only deploy key per repo; avoid a broad PAT.
- Use the token in
actions/checkoutwithrepository:andtoken:inputs.
Why → An app token is short-lived and repo-scoped, independent of any user.
Interview tip → Same principle as Jenkins GitHub App: avoid PATs.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate