Skip to content

This GitHub action configures an SSH key on a GitHub runner

License

Notifications You must be signed in to change notification settings

dym-ok/inject-ssh-key

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Inject SSH Key GitHub Action

test inject-ssh-key

This GitHub action configures an SSH key on a GitHub runner.

- name: Inject SSH Key
  uses: dym-ok/inject-ssh-key@v1
  with:
        private-key: ${{ secrets.SOME_PRIVATE_KEY }}
        host-name: 'github.com'

Subsequent steps can use SSH client or Git with git+ssh protocol with the private-key configured as the default key.

host-name input is optional and has github.com as the default values. Every IP address it resolves to is added to the ~/.ssh/known_hosts.

Note: this action requires dig which is part of the dnsutils package.

Examples of usage

Imagine you have a Python project that has dependencies in private GitHub repositories. You would need a workflow similar to this one to get your dependencies installed:

    steps:
      - uses: actions/checkout@v4
        with:
          set-safe-directory: true

      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
          cache: 'poetry'

      - uses: dym-ok/inject-ssh-key@v2
        with:
          private-key: ${{ secrets.SSH_KEY }}

      - name: install
        run: poetry install