Print auth help message based on environment#5781
Merged
Conversation
This will check if `gh` is running in a CI environment. If so, it will suggest using environment variables to set the auth token. Additionally, if the CI environment is detected to be GitHub Actions, it will provide some example code. If it is not a CI environment, it will print the standard help message.
Instead of checking if the environment variable exists, checks if it has a value. This makes it easier to test.
Resolves lint error.
mislav
suggested changes
Jun 13, 2022
This environment variable is always set to `true` in a GitHub Action. Co-authored-by: Mislav Marohnić <hi@mislav.net>
`GITHUB_TOKEN` and `GH_TOKEN` are competing options and may confuse the user. This changes to only suggesting `GH_TOKEN` if not authorized in a CI environment. Co-authored-by: Mislav Marohnić <hi@mislav.net>
Instead of building the help message step-by-step, constructs the full help message in a single heredoc function call to make the code more readable.
Contributor
Author
|
@mislav Thanks for the feedback! |
mislav
approved these changes
Jun 14, 2022
Contributor
mislav
left a comment
There was a problem hiding this comment.
Thank you! I've additionally simplified a bit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will check if
ghis running in a CI environment by checking theCIenvironment variable. If so, it will suggest using environment variables to set the auth token. Additionally, if the CI environment is detected to be GitHub Actions (GITHUB_ACTION!=""), it will provide some example code (#5387 (comment)).If it is not a CI environment, it will print the standard help message.
Fixes #5387