File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 ssh-key : ${{ secrets.DEPLOYMENT_SSH_KEY_TEST }}
2222 persist-credentials : false
2323
24+ - name : Start SSH agent and add key
25+ run : |
26+ # Create the SSH directory if it doesn't exist
27+ mkdir -p ~/.ssh
28+
29+ # Save the private SSH key from the secret into a file
30+ echo "${{ secrets.DEPLOYMENT_SSH_KEY_TEST }}" > ~/.ssh/id_rsa
31+
32+ # Set correct permissions for the private key
33+ chmod 600 ~/.ssh/id_rsa
34+
35+ # Start the SSH agent in the background
36+ eval "$(ssh-agent -s)"
37+
38+ # Add the private key to the SSH agent
39+ ssh-add ~/.ssh/id_rsa
40+
41+ # Add GitHub's public SSH keys to known_hosts to prevent host verification prompts
42+ ssh-keyscan github.com >> ~/.ssh/known_hosts
43+
44+ # Test the SSH connection to GitHub (this will fail gracefully if not successful)
45+ ssh -o StrictHostKeyChecking=no -T git@github.com || true
46+
2447 - name : Check SSH push permissions (dry-run)
2548 run : |
2649 git remote set-url origin git@github.com:${{ github.repository }}.git
You can’t perform that action at this time.
0 commit comments