Skip to content
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

fix(match): make git_private_key path absolute #21360

Merged
merged 1 commit into from Oct 7, 2023

Conversation

msamec
Copy link
Contributor

@msamec msamec commented Jun 26, 2023

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

When sending a path to a git_private_key (instead of key content), it fails when it tries to push changes to repository with error

ssh-agent bash -c 'ssh-add - <<< "id_rsa"; git push origin master'
Error loading key "(stdin)": invalid format

Resolves #19266

Description

I first noticed issue when readonly was set to true and git_private_key: 'id_rsa' in CI. It was able to clone the repo but it failed when trying to push changes back to repo. The problem started here. When it tried push the change, it couldn't find the file so it used the content of git_private_key as private key (which was id_rsa) and it failed. Next thing I tried is to check what Dir.pwdis when it clones and tries to push change and found out that when pushing changes, it changes directory to where it cloned the repo.

So for a solution I've made sure that the during initialization git_private_key is always defined as absolute path instead of relative.

Testing Steps

If you checkout the master and set readonly to true and provide git_private_key as a path (ie. id_rsa) instead sending private key content, it will fail when it tries to push new certificates/profiles back to repository.

Checking out this branch, the problem is resolved.

@getaaron
Copy link
Collaborator

getaaron commented Oct 7, 2023

Thanks for the PR! 🕺

@getaaron getaaron merged commit 970003b into fastlane:master Oct 7, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Match uses git private key to download but not to push new certs back
2 participants