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

SSH config cleanup not done #184

Open
kcarlson opened this issue May 25, 2023 · 5 comments
Open

SSH config cleanup not done #184

kcarlson opened this issue May 25, 2023 · 5 comments

Comments

@kcarlson
Copy link

The modified git config is not cleaned up after a run, e.g. the url git@key- section.
This will affect a subsequent run on, for example, a self-hosted runner.

We are using a workaround which may help someone:

- name: Restore git global config
  if: always()
  run: |
    MATCH=$(grep -o 'git@key-[^"]*\.github\.com:.*/[^"]*' ~/.gitconfig)
    git config --global --remove-section url.${MATCH}
@ILikeYourHat
Copy link

@kcarlson would this workaround also work when multiple keys are provided?

@kcarlson
Copy link
Author

I've only tested it with a single key being provided to the ssh-private-key field. If multiple keys end up under the same section in the .gitconfig, it should work, otherwise, if there are multiple sections, MATCH will have multiple matches and the ´git config´ command will not work.

damyan added a commit to ironcore-dev/metalnet that referenced this issue Oct 5, 2023
`setup-git-redirect.sh` is needed for tests, because go needs SSH
authentication, when downloading modules dependencies. The redirect
script, though, does not revert the global changes done to the git
config (in that case: SSH instead of HTTPS). The `checkout` action,
on the other hand, needs the HTTPS for checkout, because the SSH key at the
beginning of the action is no longer available, it was properly cleaned
up in the `webfactory/ssh-agent` post clean up.

Implementing workaround as in webfactory/ssh-agent#184
damyan added a commit to ironcore-dev/metalnet that referenced this issue Oct 5, 2023
`setup-git-redirect.sh` is needed for tests, because go needs SSH
authentication, when downloading modules dependencies. The redirect
script, though, does not revert the global changes done to the git
config (in that case: SSH instead of HTTPS). The `checkout` action,
on the other hand, needs the HTTPS for checkout, because the SSH key at the
beginning of the action is no longer available, it was properly cleaned
up in the `webfactory/ssh-agent` post clean up.

Implementing workaround as in webfactory/ssh-agent#184
guvenc pushed a commit to ironcore-dev/metalnet that referenced this issue Oct 5, 2023
`setup-git-redirect.sh` is needed for tests, because go needs SSH
authentication, when downloading modules dependencies. The redirect
script, though, does not revert the global changes done to the git
config (in that case: SSH instead of HTTPS). The `checkout` action,
on the other hand, needs the HTTPS for checkout, because the SSH key at the
beginning of the action is no longer available, it was properly cleaned
up in the `webfactory/ssh-agent` post clean up.

Implementing workaround as in webfactory/ssh-agent#184
guvenc pushed a commit to ironcore-dev/metalnet that referenced this issue Oct 5, 2023
`setup-git-redirect.sh` is needed for tests, because go needs SSH
authentication, when downloading modules dependencies. The redirect
script, though, does not revert the global changes done to the git
config (in that case: SSH instead of HTTPS). The `checkout` action,
on the other hand, needs the HTTPS for checkout, because the SSH key at the
beginning of the action is no longer available, it was properly cleaned
up in the `webfactory/ssh-agent` post clean up.

Implementing workaround as in webfactory/ssh-agent#184
@tonynajjar
Copy link

I also have this issue, any news?

@dcasnowdon
Copy link

This is causing problems here too. It'd be great to have a resolution if one is available.

@rickyjames35
Copy link

Thanks @kcarlson, your work around did the trick.
I'm noticing a section at the end of my action called "Post Add SSH Key"

Post job cleanup.
Stopping SSH agent
The "file" argument must be of type string. Received undefined
Error stopping the SSH agent, proceeding anyway

I'm wondering if this should be cleaning up the global gitconfig but is failing.
Either way the work around gets the job done. Thanks.

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

No branches or pull requests

5 participants