terraform-provider-github
terraform-provider-github copied to clipboard
Allow for retrieving latest prerelease as data source.
Description
Being able to retrieve the latest release from a given repository is awesome, but there's circumstances in which it'd be beneficial to grab the latest prerelease. In a continuous deployment workflow where there's a "prerelease" like environment (staging, preproduction, prerelease, rc, etc.) it'd be great to be able to pull the tag information directly from the provider, rather than having to skip out to the API to do it.
This PR introduces that functionality by allowing for passing latest_prerelease as a valid value to retrieve_by on the release data source. It's a little more involved than retrieving just the latest release, because the GitHub API at the moment doesn't allow for allowing prereleases as a flag on /latest. Instead, we're retrieving a few pages worth of releases, filtering out the prereleases, and selecting the most recently published one.
This does mean that there's a pretty substantial performance difference, as there's both more data to process and more requests being made.
@kfcampbell anything I need to do on this to get it into a reviewable state? Haven't done work on the provider before so wanted to make sure I'm not missing anything. Thanks in advance!
Still haven't had a moment to swing back to this, but I did open a post on the GitHub community for something similar: https://github.community/t/release-api-should-include-a-way-to-retrieve-the-latest-prerelease/239836
It'd be more ideal to handle it at the API level, I think, though that's an ask for core GitHub team and I imagine a fairly large one to think through.
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
👋 Hey Friends, this pull request has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!