-
-
Save masa-iwasaki/2564439555e2584387191eb525f06aec to your computer and use it in GitHub Desktop.
Login GitHub Actions VM with SSH using Tailscale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Setup Tailscale on GitHub Actions | |
on: [push] | |
jobs: | |
tailscale: | |
runs-on: ubuntu-20.04 | |
steps: | |
- run: | | |
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.gpg | sudo apt-key add - | |
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.list | sudo tee /etc/apt/sources.list.d/tailscale.list | |
- run: | | |
sudo apt-get update | |
sudo apt-get install tailscale | |
- run: | | |
mkdir ~/.ssh | |
touch ~/.ssh/authorized_keys | |
echo "$SSH_PUBKEY" >> ~/.ssh/authorized_keys | |
chmod 755 ~ | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/authorized_keys | |
env: | |
SSH_PUBKEY: ${{ secrets.SSH_PUBKEY }} | |
- run: | | |
echo "Setting up tailscale ..." | |
sudo tailscale up | |
echo -n "Done" | |
# Assume that `tailscale status` shows local IP in the first line of outputs | |
- run: | | |
HOST=`sudo tailscale status | head -n1 | tr -s ' ' | cut -d ' ' -f 1` | |
echo "ssh -i /path/to/your_key `whoami`@$HOST" | |
# If you have troubles with ssh, try watching auth.log | |
# - run: tail -f /var/log/auth.log | |
- run: | | |
sleep 300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment