This commit is contained in:
ojab 2023-11-02 23:29:11 -06:00 committed by GitHub
commit 011d961217
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 27 deletions

View file

@ -9,12 +9,14 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup key - name: Setup first key
uses: ./ uses: ./
with: with:
ssh-private-key: | ssh-private-key: ${{ secrets.MPDUDE_TEST_1_DEPLOY_KEY }}
${{ secrets.MPDUDE_TEST_1_DEPLOY_KEY }} - name: Setup second key
${{ secrets.MPDUDE_TEST_2_DEPLOY_KEY }} uses: ./
with:
ssh-private-key: ${{ secrets.MPDUDE_TEST_2_DEPLOY_KEY }}
- run: | - run: |
git clone https://github.com/mpdude/test-1.git test-1-http git clone https://github.com/mpdude/test-1.git test-1-http
git clone git@github.com:mpdude/test-1.git test-1-git git clone git@github.com:mpdude/test-1.git test-1-git
@ -43,4 +45,3 @@ jobs:
git clone https://github.com/mpdude/test-2.git test-2-http git clone https://github.com/mpdude/test-2.git test-2-http
git clone git@github.com:mpdude/test-2.git test-2-git git clone git@github.com:mpdude/test-2.git test-2-git
git clone ssh://git@github.com/mpdude/test-2.git test-2-git-ssh git clone ssh://git@github.com/mpdude/test-2.git test-2-git-ssh

26
dist/index.js vendored
View file

@ -361,21 +361,25 @@ try {
const homeSsh = homePath + '/.ssh'; const homeSsh = homePath + '/.ssh';
fs.mkdirSync(homeSsh, { recursive: true }); fs.mkdirSync(homeSsh, { recursive: true });
console.log("Starting ssh-agent");
const authSock = core.getInput('ssh-auth-sock'); const authSock = core.getInput('ssh-auth-sock');
const sshAgentArgs = (authSock && authSock.length > 0) ? ['-a', authSock] : []; const sshAgentArgs = (authSock && authSock.length > 0) ? ['-a', authSock] : [];
// Extract auth socket path and agent pid and set them as job variables if (child_process.spawnSync(sshAdd, ['-l'], { env: { ...process.env, SSH_AUTH_SOCK: authSock || process.env.SSH_AUTH_SOCK } }).status === 0) {
child_process.execFileSync(sshAgentCmd, sshAgentArgs).toString().split("\n").forEach(function(line) { console.log('ssh-agent is already running, not starting a new one');
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line); } else {
console.log("Starting ssh-agent");
if (matches && matches.length > 0) { // Extract auth socket path and agent pid and set them as job variables
// This will also set process.env accordingly, so changes take effect for this script child_process.execFileSync(sshAgent, sshAgentArgs).toString().split("\n").forEach(function(line) {
core.exportVariable(matches[1], matches[2]) const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line);
console.log(`${matches[1]}=${matches[2]}`);
} if (matches && matches.length > 0) {
}); // This will also set process.env accordingly, so changes take effect for this script
core.exportVariable(matches[1], matches[2]);
console.log(`${matches[1]}=${matches[2]}`);
}
});
}
console.log("Adding private key(s) to agent"); console.log("Adding private key(s) to agent");

View file

@ -25,21 +25,25 @@ try {
const homeSsh = homePath + '/.ssh'; const homeSsh = homePath + '/.ssh';
fs.mkdirSync(homeSsh, { recursive: true }); fs.mkdirSync(homeSsh, { recursive: true });
console.log("Starting ssh-agent");
const authSock = core.getInput('ssh-auth-sock'); const authSock = core.getInput('ssh-auth-sock');
const sshAgentArgs = (authSock && authSock.length > 0) ? ['-a', authSock] : []; const sshAgentArgs = (authSock && authSock.length > 0) ? ['-a', authSock] : [];
// Extract auth socket path and agent pid and set them as job variables if (child_process.spawnSync(sshAdd, ['-l'], { env: { ...process.env, SSH_AUTH_SOCK: authSock || process.env.SSH_AUTH_SOCK } }).status === 0) {
child_process.execFileSync(sshAgentCmd, sshAgentArgs).toString().split("\n").forEach(function(line) { console.log('ssh-agent is already running, not starting a new one');
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line); } else {
console.log("Starting ssh-agent");
if (matches && matches.length > 0) { // Extract auth socket path and agent pid and set them as job variables
// This will also set process.env accordingly, so changes take effect for this script child_process.execFileSync(sshAgent, sshAgentArgs).toString().split("\n").forEach(function(line) {
core.exportVariable(matches[1], matches[2]) const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line);
console.log(`${matches[1]}=${matches[2]}`);
} if (matches && matches.length > 0) {
}); // This will also set process.env accordingly, so changes take effect for this script
core.exportVariable(matches[1], matches[2]);
console.log(`${matches[1]}=${matches[2]}`);
}
});
}
console.log("Adding private key(s) to agent"); console.log("Adding private key(s) to agent");