Describe the need
When Terraform runs inside a GitHub Actions workflow, the runner already exposes the current repository via GITHUB_REPOSITORY (owner/repo), and the provider already sources owner/token from the environment (GITHUB_OWNER, GITHUB_TOKEN). However, there is no way to reference the repository the workflow is running in without declaring an input variable and wiring TF_VAR_repository: ${{ github.event.repository.name }} in the workflow.
Today the only env-only (no-variable) workaround is an external data source shelling out to read $GITHUB_REPOSITORY + jq, which is brittle. It would be valuable for the provider to resolve the current repository directly from the environment, mirroring how the provider already resolves owner.
Note that the existing github_repository data source requires name or full_name and errors otherwise ("one of full_name or name has to be provided"), so there is no env fallback available today.
Possible approaches (deferring the final shape to maintainers):
-
Extend github_repository — make name/full_name optional and, when both are omitted, fall back to GITHUB_REPOSITORY. Smallest surface-area change; reuses the existing data source.
data "github_repository" "current" {} # name/full_name omitted -> $GITHUB_REPOSITORY
-
New dedicated github_repository_current data source — no required inputs; resolves the current repo from GITHUB_REPOSITORY and exposes the same attributes as github_repository. Clearest intent, explicit and discoverable.
data "github_repository_current" "this" {}
output "name" { value = data.github_repository_current.this.name }
-
New broader github_context data source — exposes Actions context (repository, owner, ref, sha, ...) from the runner env, of which repository is one field.
data "github_context" "this" {}
output "repo" { value = data.github_context.this.repository }
Recommendation: option 1 (extend the existing data source) is the least invasive, with option 2 (github_repository_current) as a clean explicit alternative if maintainers prefer not to overload github_repository.
GitHub Installation Type
Relevant log output
None.
Code of Conduct
Describe the need
When Terraform runs inside a GitHub Actions workflow, the runner already exposes the current repository via
GITHUB_REPOSITORY(owner/repo), and the provider already sourcesowner/tokenfrom the environment (GITHUB_OWNER,GITHUB_TOKEN). However, there is no way to reference the repository the workflow is running in without declaring an input variable and wiringTF_VAR_repository: ${{ github.event.repository.name }}in the workflow.Today the only env-only (no-variable) workaround is an
externaldata source shelling out to read$GITHUB_REPOSITORY+jq, which is brittle. It would be valuable for the provider to resolve the current repository directly from the environment, mirroring how the provider already resolvesowner.Note that the existing
github_repositorydata source requiresnameorfull_nameand errors otherwise ("one of full_name or name has to be provided"), so there is no env fallback available today.Possible approaches (deferring the final shape to maintainers):
Extend
github_repository— makename/full_nameoptional and, when both are omitted, fall back toGITHUB_REPOSITORY. Smallest surface-area change; reuses the existing data source.New dedicated
github_repository_currentdata source — no required inputs; resolves the current repo fromGITHUB_REPOSITORYand exposes the same attributes asgithub_repository. Clearest intent, explicit and discoverable.New broader
github_contextdata source — exposes Actions context (repository,owner,ref,sha, ...) from the runner env, of which repository is one field.Recommendation: option 1 (extend the existing data source) is the least invasive, with option 2 (
github_repository_current) as a clean explicit alternative if maintainers prefer not to overloadgithub_repository.GitHub Installation Type
Relevant log output
None.
Code of Conduct