6 Commits

Author SHA1 Message Date
Matthias Pigulla
5f066a372e Prepare a 0.5.3 release 2021-06-11 15:18:45 +02:00
Maciej Pasternacki
a45226bfaf Use execFileSync to clean up (#80)
execSync just started a second ssh-agent. `['-k']` argument was
treated as options, it didn't have `stdio` set, so stdio was piped and
returned (and ignored).
2021-06-11 15:17:22 +02:00
Matthias Pigulla
81d965f2bd Tix a fypo 2021-06-03 23:33:40 +02:00
Matthias Pigulla
515d164e78 Run cleanup (post) step also on failure (#79)
According to https://github.com/actions/runner/issues/987, this should run the post step (cleanup.js) also when a workflow fails.

Probably most important on self-hosted runners that are not ephemeral, to terminate SSH agents from failed jobs as well.
2021-06-02 22:15:05 +02:00
Matthias Pigulla
8569bedfe0 Mention "-scmProvider system" for XCode builds/Swift Package Manager
Co-authored-by: rr-james-hickman <james.hickman@rakuten.com>
2021-05-27 20:11:56 +00:00
Matthias Pigulla
98f76b1158 Give an example of how to add a key comment
Co-authored-by: rr-james-hickman <james.hickman@rakuten.com>
2021-05-27 20:05:28 +00:00
4 changed files with 13 additions and 10 deletions

View File

@@ -33,9 +33,9 @@ jobs:
... ...
steps: steps:
- actions/checkout@v2 - actions/checkout@v2
# Make sure the @v0.5.2 matches the current version of the # Make sure the @v0.5.3 matches the current version of the
# action # action
- uses: webfactory/ssh-agent@v0.5.2 - uses: webfactory/ssh-agent@v0.5.3
with: with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- ... other steps - ... other steps
@@ -50,7 +50,7 @@ You can set up different keys as different secrets and pass them all to the acti
```yaml ```yaml
# ... contens as before # ... contens as before
- uses: webfactory/ssh-agent@v0.5.2 - uses: webfactory/ssh-agent@v0.5.3
with: with:
ssh-private-key: | ssh-private-key: |
${{ secrets.FIRST_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. 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. 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`. 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. 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 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 ## What this Action *cannot* do for you
The following items are not issues, but beyond what this Action is supposed to do. The following items are not issues, but beyond what this Action is supposed to do.

View File

@@ -10,6 +10,7 @@ runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'
post: 'dist/cleanup.js' post: 'dist/cleanup.js'
post-if: 'always()'
branding: branding:
icon: loader icon: loader
color: 'yellow' color: 'yellow'

View File

@@ -1,12 +1,11 @@
const core = require('@actions/core'); const core = require('@actions/core');
const { execSync } = require('child_process'); const { execFileSync } = require('child_process');
const { sshAgent } = require('./paths.js'); const { sshAgent } = require('./paths.js');
try { try {
// Kill the started SSH agent // Kill the started SSH agent
console.log('Stopping SSH agent'); console.log('Stopping SSH agent');
execSync(sshAgent, ['-k'], { stdio: 'inherit' }); execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
} catch (error) { } catch (error) {
console.log(error.message); console.log(error.message);
console.log('Error stopping the SSH agent, proceeding anyway'); console.log('Error stopping the SSH agent, proceeding anyway');

5
dist/cleanup.js vendored
View File

@@ -123,14 +123,13 @@ module.exports = require("child_process");
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { /***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
const core = __webpack_require__(470); const core = __webpack_require__(470);
const { execSync } = __webpack_require__(129); const { execFileSync } = __webpack_require__(129);
const { sshAgent } = __webpack_require__(972); const { sshAgent } = __webpack_require__(972);
try { try {
// Kill the started SSH agent // Kill the started SSH agent
console.log('Stopping SSH agent'); console.log('Stopping SSH agent');
execSync(sshAgent, ['-k'], { stdio: 'inherit' }); execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
} catch (error) { } catch (error) {
console.log(error.message); console.log(error.message);
console.log('Error stopping the SSH agent, proceeding anyway'); console.log('Error stopping the SSH agent, proceeding anyway');