lindell / multi-gitter

Update multiple repositories in with one command
Apache License 2.0
819 stars 64 forks source link

GITHUB_TOKEN is not being used by `multi-gitter` #453

Closed ruzickap closed 5 months ago

ruzickap commented 5 months ago

Describe the bug I have my GITHUB_TOKEN properly exported as environment variable, but multi-gitter ignores the value.

To Reproduce

My config file:

$ cat ~/.multi-gitter/config
repo:
  - my_username/my_repo_1
  - my_username/my_repo_2
  - my_username/my_repo_3

My GitHub Token:

$ echo "${GITHUB_TOKEN}"
github_pat_11.......

multi-gitter is asking to set the token - but it is already set as environment variable GITHUB_TOKEN:

$ multi-gitter status
Error: either the --token flag or the GITHUB_TOKEN
...

If I run the command + specify the GITHUB_TOKEN as cli parameter - the it is working like expected:

$ multi-gitter status --token "${GITHUB_TOKEN}"
my_username/my_repo_1 #160: Success
my_username/my_repo_2 #100: Success
my_username/my_repo_3 #221: Success

Expected behavior multi-gitter should use GITHUB_TOKEN environment variable whenever it is defined.

Additional context

Version:

❯ multi-gitter version
multi-gitter version: 0.49.1
Release-Date: 2024-01-06
Go version: go1.21.5
OS: darwin
Arch: arm64
Commit: ee1a291a17f941631207c1a5f4fc2a626afe8315
lindell commented 5 months ago

Does the same thing happen when you remove the config file and out the repos as CLI arguments?

ruzickap commented 5 months ago

If I remove the config file ~/.multi-gitter/config it is not working too:

$ multi-gitter status --repo my_username/my_repo_1
Error: either the --token flag or the GITHUB_TOKEN/GITLAB_TOKEN/GITEA_TOKEN/BITBUCKET_SERVER_TOKEN environment variable has to be set
Usage:
...

It only works properly when I set the GH Token as parameter:

$ multi-gitter status --token "${GITHUB_TOKEN}" --repo my_username/my_repo_1
my_username/my_repo_1 #160: Merged

Thank you...

lindell commented 5 months ago

I can't repro this. And looking at the code, it doesn't make sense that it would not read the variable if it's exported.

Are you sure it is exported as you write in the initial post. Not just set in the shell?

# exporting
export GITHUB_TOKEN="github_pat_11......."
# just setting it in the current shell
GITHUB_TOKEN="github_pat_11......."
ruzickap commented 5 months ago

Thank you...

You are right - the export helped...

This is needed in my environment:

export GITHUB_TOKEN="github_pat_11......."

Thanks again