-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] How to authenticate in GitHub Action using conan.tools.scm.Git
#13167
Comments
Uhm, this is interesting. I don't know much about Github actions yet, I would assume that it would be possible to access the same repo that is being processed, but apparently it is not possible by default. I see Github actions can define something like
But that would work only if passed in the url like In general this feature assumes that there is already a git system authentication, like using ssh-keys or something like that. Ephemeral CIs don't work this way, this is definitely something we should investigate a bit further. Any Github action experienced user can provide some ideas? |
I just implemented the following workaround: def source(self):
token = os.environ.get('GITHUB_TOKEN')
sources = self.conan_data['sources']
git = Git(self)
git.fetch_commit(
url=sources['url'] if not token else \
sources['url'].replace(
'https://github.com',
'https://oauth2:{}@github.com'.format(token)
),
commit=sources['commit']
) This works when you set the token secret as environment variable of the job: jobs:
conan:
name: Conan package
env:
GITHUB_TOKEN: ${{ github.token }}
|
Great point @daniel-eiband-snkeos , thanks for sharing. I'd still love to learn if there is some Github action built-in way so it is possible to clone using the bare URL without auth. |
This has been inactive for a while, but I'd still like to learn if there are other possibilities for GH actions there. |
Hi all, I am following up on this. The docs page in https://docs.conan.io/2/examples/tools/scm/git/capture_scm/git_capture_scm.html#credentials-management was added in conan-io/docs#3112. I have just tried this and it seems to work great:
I think we can close this ticket as solved? What do you think? Thanks for your feedback! |
I have checked with the team, our conclusions:
This scm approach can also work well with Trying to provide a built-in feature that uses in-url tokens or the like is kind of risky, so it wouldn't be planned at this moment. I am closing this ticket as solved, if there is any pending question or new feedback, I'd recommend to create a new one. Thanks very much for your feedback! |
What is your question?
I'm trying to refactor my recipes and make them ready for Conan 2.0. The migration guide has an example that shows the usage of
conan.tools.scm.Git
. However when executingconan create
inside a GitHub action of a private repository with the newGit
helper then I get the following error:What is the recommended way of passing the
GITHUB_TOKEN
secret or authenticate in general?Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: