Do not make assumptions about environment (CI - Github Actions)
chrisgoffinet opened this issue · 3 comments
I can understand you were trying to make things more automatic but please replace the the check for at:
https://github.com/posener/goreadme/blob/master/cmd/goreadme/main.go#L120
To require this to be a flag instead of assuming CI
is an environment variable being set by Github actions. This tripped me up because I didn't want to use your action because it tries to commit the changes. I opt'd out of using the action to run the tool directly, but my workflow was failing due to this CI assumption. I managed to get around this by overriding the env of CI to false but I would hate for others to run into this and get stuck.
I would suggest updating your github action to have an input for CI mode and the ability to skip commiting the updated README.
Hey, sorry for the late reply.
Can you explain in which environment you had CI=true
? This is how Github Actions tells programs that they are running as Github Actions. See this doc
Correct, I was aware. I was just mentioning it would be helpful to not assume things like CI
, and instead put it behind a flag. The use case was that I am running goreadme
in Github actions but I don't want to have this portion of the code ran:
https://github.com/posener/goreadme/blob/master/cmd/goreadme/main.go#L124
Coming back to this, I think it would be okay to assume CI
but have a flag to disable the above if desired. I had to set CI: false
to skip this.
Hello 👋
First, thanks for you work, it's really helpful 👌
But indeed, assuming that CI=true
means running the command under GHAction context is not accurate.
See there for instance, travis uses the same env variable.
The following default environment variables are available to all builds.
CI=true
IMO, it would be great to separate the CLI command from the github action (=move what you are specifically doing for GHAction context inside a dedicated repo, or move the CLI command outside of this repo and keep only code not related to GHAction context, up to you)
It's a bit scary to figure out by reading the code that command is actually relying on stuff named GITHUB_TOKEN
, which are really sensitive values 😬
That being said, by default, github token is not available inside env variables, but it's anyway scary to read that in what seems to be a standalone CLI command
Meanwhile, I use CI: false
, like mentioned above