-
Notifications
You must be signed in to change notification settings - Fork 265
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
[BUGFIX] Not working properly on self-hosted runners #27
Conversation
* remove fixed default auth socket path * call `ssh-agent` with auth socket path, if not explicitly given, to let the system choose the path * read SSH_AUTH_SOCKET and SSH_AGENT_PID from `ssh-agent` command output and add the as variables
Maybe I'm reading this incorrectly, but wouldn't this kill the agent for other runners on the same machine? |
Adding the run ID seems like a wise choice to ensure the agent is using a unique |
@rbellamy As far as I know, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @thommyhh for working on this! I really appreciate the effort, in particular when it comes to parsing the agent's output.
Apart from the minor comments I left, could you have a look at https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#post ? I think we could setup a post
job that makes this action always clean up its own agent instance automatically.
README.md
Outdated
## Exported variables | ||
The action exports `SSH_AUTH_SOCK` and `SSH_AGENT_PID` through the Github Actions core module. | ||
The `$SSH_AUTH_SOCK` is used by several applications like git or rsync to connect to the SSH authentication agent. | ||
The `$SSH_AGENT_PID` can be used to kill the SSH agent, e.g. when using on a self-hosted runner: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd shorten this to only say "... contains the process id of the agent running for this job". I think it should be the action's responsibility to kill the agent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a post action to kill the agent. Seems to work as expected.
@@ -62,7 +62,7 @@ try { | |||
const home = process.env['HOME']; | |||
const homeSsh = home + '/.ssh'; | |||
|
|||
const privateKey = core.getInput('ssh-private-key').trim(); | |||
const privateKey = core.getInput('ssh-private-key'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase this PR against master
please? Then this change should go away.
@@ -71,14 +71,27 @@ try { | |||
} | |||
|
|||
console.log(`Adding github.com keys to ${homeSsh}/known_hosts`); | |||
fs.mkdirSync(homeSsh, { recursive: true}); | |||
fs.mkdirSync(homeSsh, { recursive: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, should go away with a rebase.
if (authSock && authSock.length > 0) { | ||
sshAgentOutput = child_process.execFileSync('ssh-agent', ['-a', authSock]); | ||
} else { | ||
sshAgentOutput = child_process.execFileSync('ssh-agent') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slight BC break since now not providing a value for the ssh-auth-sock
input will bind it to a random port, instead of the fixed value we used previously. (Yes, I completely understand that this is part of the goal to be able to run multiple instances in parallel; just sayin').
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're still in the 0.x version ranges, IMO nothing we should worry about too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It binds to a random socket file, just for being precise. I don't think the value matters as long as it written to the $SSH_AUTH_SOCK
variable.
* add `cleanup.js` for stopping the ssh-agent after the job is done * add `scripts/build.js` to make it easier to build the files in `dist/` * update README * remove meaningless dependency `child_process` (its a node core package) * update `@actions/core` to `^1.2.4`
@mpdude I updated the branch with the latest changes from master, but the changes did not disappear. I don't know, how to trigger GitHub to re-read the base branch (tried changing base). I also added the post action to kill the agent automatically, as suggested. I wondered, if there is something like a post job script, to clean things up. |
I think you can merge master and then push? |
@zhigang1992 |
I have released 0.3.0 with this change. Thank you @thommyhh and everyone involved! |
ssh-agent
with auth socket path, if not explicitly given,to let the system choose the path
ssh-agent
command outputand export them as variables
dist/index.js
Fixes #16