-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi Marco,
I have many packages that use private SPM dependencies via github.
Common method to allow github workflows to support private dependencies in any form (could be submodule, could be private package via git@github.com:username/repo
) is to use old school trick of mapping ssh deploy keys and virtual ssh hostnames along with .gitconfig
url...insteadOf
to your private repositories.
This can be automated via great action from shaunco: https://github.com/shaunco/ssh-agent/tree/git-repo-mapping.
Here is an example swift build && swift test
workflow that uses private swift dependencies that I am using:
name: Swift Build & Test
on: [workflow_dispatch, push]
jobs:
swift:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
swift: ["5.5", "5.6"]
steps:
- uses: shaunco/ssh-agent@git-repo-mapping
with:
ssh-private-key: |
${{ secrets.REPO1_SSH_PRIVATE_KEY}}
${{ secrets.REPO2_SSH_PRIVATE_KEY}}
repo-mappings: |
github.com/mman/repo1.git
github.com/mman/repo2.git
- uses: fwal/setup-swift@v1.14.0
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Build
run: swift build
- name: Test
run: swift test
I have tried to use the same approach with your action, but it does not work properly. I have also tried with https://github.com/getsidetrack/action-xcodeproj-spm-update and there it works nicely.
So I started investigating what is the issue and I think I have found it:
The shaunco/ssh-agent@git-repo-mapping
will populate ~/.gitconfig
and ~/.ssh/*
of the workflow job with private keys and hostname aliases for all the private dependencies that you may have. The ~/.ssh/*
private keys are then added to the workflow internal ssh-agent
and used by the subsequent steps. So for example xcodebuild
used by the https://github.com/getsidetrack/action-xcodeproj-spm-update will pick up the new config nicely and will happily check dependencies and create a PR.
But your action will fail because it uses a step to invoke swift-release-notes
via nested docker
and the ~/.ssh/config
and ~/.gitconfig
are not properly passed to the docker step.
I have been able to overcome this limitation by somehow (hard copy, volume mount in case of docker build
) pushing the ~/.ssh
and ~/.gitconfig
to the docker step so that it can properly access the private dependencies, but I have not found an easy way to do this with your workflow without forking and modifying it heavily.
I am not necessarily suggesting I know how to fix this properly, but I just want the issue to exist here for anybody hitting the same limitation.
I will probably try to work around this limitation by skipping the swift-release-notes
binary invocation, and by simply invoking swift package update
directly and comparing the md5sum before/after the same way action-xcodeproj-spm-update
does it.
Another option could be to build swift-release-notes
directly inside the job, and thus avoiding jumping to another nested docker step, which will help inherit the job environment.
Thoughts?