mirror of
https://github.com/webfactory/ssh-agent.git
synced 2026-03-15 07:49:07 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f066a372e | ||
|
|
a45226bfaf | ||
|
|
81d965f2bd | ||
|
|
515d164e78 | ||
|
|
8569bedfe0 | ||
|
|
98f76b1158 | ||
|
|
cb8b21017a | ||
|
|
aed5400f20 | ||
|
|
4681241867 |
12
README.md
12
README.md
@@ -33,9 +33,9 @@ jobs:
|
||||
...
|
||||
steps:
|
||||
- actions/checkout@v2
|
||||
# Make sure the @v0.5.1 matches the current version of the
|
||||
# Make sure the @v0.5.3 matches the current version of the
|
||||
# action
|
||||
- uses: webfactory/ssh-agent@v0.5.1
|
||||
- uses: webfactory/ssh-agent@v0.5.3
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
- ... other steps
|
||||
@@ -50,7 +50,7 @@ You can set up different keys as different secrets and pass them all to the acti
|
||||
|
||||
```yaml
|
||||
# ... contens as before
|
||||
- uses: webfactory/ssh-agent@v0.5.1
|
||||
- uses: webfactory/ssh-agent@v0.5.3
|
||||
with:
|
||||
ssh-private-key: |
|
||||
${{ secrets.FIRST_KEY }}
|
||||
@@ -68,7 +68,7 @@ When using **Github deploy keys**, GitHub servers will accept the _first_ known
|
||||
|
||||
To support picking the right key in this use case, this action scans _key comments_ and will set up extra Git and SSH configuration to make things work.
|
||||
|
||||
1. When creating the deploy key for a repository like `git@github.com:owner/repo.git` or `https://github.com/owner/repo`, put that URL into the key comment.
|
||||
1. When creating the deploy key for a repository like `git@github.com:owner/repo.git` or `https://github.com/owner/repo`, put that URL into the key comment. (Hint: Try `ssh-keygen ... -C "git@github.com:owner/repo.git"`.)
|
||||
2. After keys have been added to the agent, this action will scan the key comments.
|
||||
3. For key comments containing such URLs, a Git config setting is written that uses [`url.<base>.insteadof`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf). It will redirect `git` requests to URLs starting with either `https://github.com/owner/repo` or `git@github.com:owner/repo` to a fake hostname/URL like `git@...some.hash...:owner/repo`.
|
||||
4. An SSH configuration section is generated that applies to the fake hostname. It will map the SSH connection back to `github.com`, while at the same time pointing SSH to a file containing the appropriate key's public part. That will make SSH use the right key when connecting to GitHub.com.
|
||||
@@ -126,6 +126,10 @@ env:
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
```
|
||||
|
||||
### Using Deploy Keys with Swift Package Manager
|
||||
|
||||
`xcodebuild` by default uses Xcode's built-in Git tooling. If you want to use GitHub Deploy Keys as supported by this action, however, that version of Git will lack the necessary URL remapping. In this case, pass `-scmProvider system` to the `xcodebuild` command, as mentioned in [Apple's documentation](https://developer.apple.com/documentation/swift_packages/building_swift_packages_or_apps_that_use_them_in_continuous_integration_workflows#3680255).
|
||||
|
||||
## What this Action *cannot* do for you
|
||||
|
||||
The following items are not issues, but beyond what this Action is supposed to do.
|
||||
|
||||
@@ -10,6 +10,7 @@ runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
post: 'dist/cleanup.js'
|
||||
post-if: 'always()'
|
||||
branding:
|
||||
icon: loader
|
||||
color: 'yellow'
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
const core = require('@actions/core');
|
||||
const { execSync } = require('child_process');
|
||||
const { execFileSync } = require('child_process');
|
||||
const { sshAgent } = require('./paths.js');
|
||||
|
||||
try {
|
||||
// Kill the started SSH agent
|
||||
console.log('Stopping SSH agent');
|
||||
execSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
|
||||
execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
console.log('Error stopping the SSH agent, proceeding anyway');
|
||||
|
||||
5
dist/cleanup.js
vendored
5
dist/cleanup.js
vendored
@@ -123,14 +123,13 @@ module.exports = require("child_process");
|
||||
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
|
||||
|
||||
const core = __webpack_require__(470);
|
||||
const { execSync } = __webpack_require__(129);
|
||||
const { execFileSync } = __webpack_require__(129);
|
||||
const { sshAgent } = __webpack_require__(972);
|
||||
|
||||
try {
|
||||
// Kill the started SSH agent
|
||||
console.log('Stopping SSH agent');
|
||||
execSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
|
||||
execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
console.log('Error stopping the SSH agent, proceeding anyway');
|
||||
|
||||
4
dist/index.js
vendored
4
dist/index.js
vendored
@@ -167,9 +167,11 @@ try {
|
||||
console.log('Configuring deployment key(s)');
|
||||
|
||||
child_process.execFileSync(sshAdd, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
|
||||
|
||||
if (!parts) {
|
||||
console.log(`Comment for key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
4
index.js
4
index.js
@@ -50,9 +50,11 @@ try {
|
||||
console.log('Configuring deployment key(s)');
|
||||
|
||||
child_process.execFileSync(sshAdd, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
|
||||
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
|
||||
|
||||
if (!parts) {
|
||||
console.log(`Comment for key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user