integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
863 stars 708 forks source link

[FEAT]: Support Fetching Files from Specific Commit SHA in github_repository_file Data Source #2227

Open shmuelarditi opened 2 months ago

shmuelarditi commented 2 months ago

Describe the need

I am seeking to enhance the github_repository_file data source by introducing the ability to fetch files from a specific commit SHA, in addition to the current capability of fetching from the tip of a branch. This functionality is aimed at solving the problem of fetching versions of files that exists at a specific point in the repository's history.

The introduction of direct commit SHA specification for file retrieval would significantly improve configuration management within Terraform workflows, especially in CI/CD processes where specific versions of files are critical. This feature not only enhances precision and reliability but also aligns with best practices in automation and version control. Considering the GitHub API already supports file retrieval at specific commits, incorporating this feature into the Terraform GitHub provider appears both practical and highly beneficial.

something like:

data "github_repository_file" "example" {
  repository = "example-repo"
  file       = "path/to/myfile.txt"
  commit_sha = "abc123def456ghi789jkl"
}

SDK Version

This feature suggestion does not apply to a specific SDK version.

API Version

this feature would leverage the existing capabilities of the GitHub REST API, which already supports fetching file contents at a specific commit SHA through the ref parameter.

Relevant log output

No response

Code of Conduct

liel-cohen-moovit commented 2 months ago

Totally on board with this! I've faced the same issues and being able to grab files by commit SHA would be a game-changer for our CI/CD setups. Really hope they roll this out soon—it'd make things way smoother.

wyatterp365 commented 2 months ago

Describe the need

I am seeking to enhance the github_repository_file data source by introducing the ability to fetch files from a specific commit SHA, in addition to the current capability of fetching from the tip of a branch. This functionality is aimed at solving the problem of fetching versions of files that exists at a specific point in the repository's history.

The introduction of direct commit SHA specification for file retrieval would significantly improve configuration management within Terraform workflows, especially in CI/CD processes where specific versions of files are critical. This feature not only enhances precision and reliability but also aligns with best practices in automation and version control. Considering the GitHub API already supports file retrieval at specific commits, incorporating this feature into the Terraform GitHub provider appears both practical and highly beneficial.

something like:

data "github_repository_file" "example" {
  repository = "example-repo"
  file       = "path/to/myfile.txt"
  commit_sha = "abc123def456ghi789jkl"
}

SDK Version

This feature suggestion does not apply to a specific SDK version.

API Version

this feature would leverage the existing capabilities of the GitHub REST API, which already supports fetching file contents at a specific commit SHA through the ref parameter.

Relevant log output

No response

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct