Skip to content

Implement ssh-key and ssh-known-hosts support for GHA#902

Draft
mathias-luedtke wants to merge 1 commit into
ros-industrial:masterfrom
mathias-luedtke:feature/github-ssh-key
Draft

Implement ssh-key and ssh-known-hosts support for GHA#902
mathias-luedtke wants to merge 1 commit into
ros-industrial:masterfrom
mathias-luedtke:feature/github-ssh-key

Conversation

@mathias-luedtke

@mathias-luedtke mathias-luedtke commented Feb 2, 2025

Copy link
Copy Markdown
Member
test_ici:
    runs-on: ubuntu-latest
    steps:
      - uses: 'mathias-luedtke/industrial_ci@feature/github-ssh-key'
        with:
          ssh-key: ${{ secrets.private_key }}
        env:
          ROS_DISTRO: "humble"
          TARGET_WORKSPACE: "git+ssh://git@github.com/mathias-luedtke/testpriv.git#main"

@AndyZe

AndyZe commented Feb 3, 2025

Copy link
Copy Markdown

Doesn't seem to work for me yet

Error: Unable to resolve action `myorg/myrepo1`, repository not found. Unable to resolve action `myorg/myrepo2`, repository not found. Unable to resolve action `myorg/myrepo3`, repository not found....

Here's my industrial_ci.yml in case I made a mistake there:

jobs:
  industrial_ci:
    strategy:
      matrix:
        env:
          - {ROS_DISTRO: humble, ROS_REPO: main}
    env:
      CCACHE_DIR: "${{ github.workspace }}/.ccache" # Enable ccache
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4 # clone target repository
      - uses: 'myorg/myrepo1@main'
        with:
          ssh-key: ${{ secrets.REPO1 }}
      - uses: 'myorg/myrepo2@main'
        with:
          ssh-key: ${{ secrets.REPO2 }}
      - uses: 'myorg/myrepo3@ros2'
        with:
          ssh-key: ${{ secrets.REPO3 }}
...
      - uses: actions/cache@v4 # fetch/store the directory used by ccache before/after the ci run
        with:
          path: ${{ env.CCACHE_DIR }}
          # This configuration will always create a new ccache cache starting off from the previous one (if any).
          # In this simple version it will be shared between all builds of the same ROS_REPO and ROS_REPO
          # and might need some fine-tuning to match the use case
          key: ccache-${{ matrix.ROS_DISTRO }}-${{ matrix.ROS_REPO }}-${{github.run_id}}
          restore-keys: |
            ccache-${{ matrix.ROS_DISTRO }}-${{ matrix.ROS_REPO }}-
      - uses: 'mathias-luedtke/industrial_ci@feature/github-ssh-key'
        env: ${{matrix.env}}

@mathias-luedtke

Copy link
Copy Markdown
Member Author

@AndyZe: My example only works for single deploy key and ideally with a *.repos file.
If you need multiple deploy keys, you could use https://github.com/webfactory/ssh-agent, like in https://github.com/mathias-luedtke/sshtest/blob/main/.github/workflows/main.yml#L40

@AndyZe

AndyZe commented Feb 5, 2025

Copy link
Copy Markdown

Alright, well I'm going to stick with what I documented in #900 then. It works well, not too difficult.

@mathias-luedtke mathias-luedtke marked this pull request as draft September 11, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants