Skip to content

Commit 4c87dac

Browse files
committed
Use ssh-agent for SSH authentication in CI
- Start ssh-agent and add deploy key to it - Export SSH_AUTH_SOCK to GITHUB_ENV for subsequent steps - This allows libgit2 (used by Julia) to authenticate properly
1 parent cdcbdab commit 4c87dac

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

.github/workflows/CI.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ jobs:
3333
- uses: julia-actions/cache@v2
3434
- name: Setup SSH for private repos
3535
run: |
36+
# Add GitHub to known hosts
3637
mkdir -p ~/.ssh
37-
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy_key
38-
chmod 600 ~/.ssh/deploy_key
3938
ssh-keyscan github.com >> ~/.ssh/known_hosts
40-
echo "Host github.com" >> ~/.ssh/config
41-
echo " HostName github.com" >> ~/.ssh/config
42-
echo " User git" >> ~/.ssh/config
43-
echo " IdentityFile ~/.ssh/deploy_key" >> ~/.ssh/config
44-
echo " IdentitiesOnly yes" >> ~/.ssh/config
45-
chmod 600 ~/.ssh/config
39+
40+
# Start ssh-agent and export variables for subsequent steps
41+
eval "$(ssh-agent -s)"
42+
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
43+
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
44+
45+
# Add the deploy key to ssh-agent
46+
echo "${{ secrets.DEPLOY_KEY }}" | ssh-add -
4647
- uses: julia-actions/julia-buildpkg@v1
4748
- uses: julia-actions/julia-runtest@v1
4849
- uses: julia-actions/julia-processcoverage@v1

0 commit comments

Comments
 (0)