-
Notifications
You must be signed in to change notification settings - Fork 286
Closed
Description
Not exactly a bug, but I found it challenging to find a solution that works with docker build when using multiple deploy keys. The reason seems to be that the build container doesn't have the ssh and git config necessary to map the right key to the right repo.
For example:
- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.0
with:
ssh-private-key: |
${{ secrets.DEPLOY_KEY_A }}
${{ secrets.DEPLOY_KEY_B }}
- name: Works Well!
run: |
git clone github.com/me/private-repo-a
git clone github.com/me/private-repo-b
- name: Doesn't work :(
run: |
cat > Dockerfile <<EOF
FROM debian
RUN --mount=type=ssh git clone github.com/me/private-repo-a
RUN --mount=type=ssh git clone github.com/me/private-repo-b
EOF
docker build --ssh default .
The docker build has access to the keys, but it doesn't use the right one for each repo, so one of the checkouts will fail.
My solution was to copy the config into the container:
run: |
mkdir root-config
cp -r ~/.gitconfig ~/.ssh root-config/
docker build ... .
And in my Dockerfile:
COPY root-config /root/
RUN sed 's|/home/runner|/root|g' -i.bak /root/.ssh/config
That works, but it feels pretty hacky. I was just wondering if anyone can come up with a better way/wanted to document a way to make it work.
radzki, flipbit03, andrewccrypto and farnsworth
Metadata
Metadata
Assignees
Labels
No labels