I’m having a small issue with GitHub Actions and I hope you can help me out in some way. Currently, the project needs to use a private GEM from our own organization, and due to external reasons, we’ve had to define an alias in the GitHub host configuration. So, in the current Gemfile, it looks like this:
gem 'private_gem', '>= 1.0.0', git: "[email protected]:organization/private_gem.git"
(I’ve replaced some names for privacy reasons.)
With the Gemfile set up this way, it was necessary to create a config file inside the ~/.ssh folder with the following structure:
Host github-alias.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
This way, I defined an alias so that when the bundle fetches the GEM, it looks inside GitHub.
So, this setup worked perfectly on my personal machine. However, I haven’t had the same luck with GitHub Actions.
When it tries to run bundle install
, it gives me the following error:
Fetching bundler 2.3.22
Installing bundler 2.3.22
Fetching gem metadata from https://rubygems.org/..........
Fetching https://github.com/kreeti/kt-paperclip.git
Fetching [email protected]:organization/private_gem.git
ssh: Could not resolve hostname github-alias.com: Name or service not known
fatal: Could not read from remote repository.
I don’t quite understand the reason, because in the CI.yml file, I’ve defined the SSH and host in the same way as on my personal machine. Here’s the CI code:
- uses: actions/checkout@v4
- name: Setup SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
echo "Host github-alias.com" >> ~/.ssh/config
echo " HostName github.com" >> ~/.ssh/config
echo " PreferredAuthentications publickey" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Install gems
run: bundle install
That’s all the information I can provide at the moment. I’ve tried debugging the config file and it seems to be created correctly. Thanks in advance for your help.