GitHub Setup
10 minutesPrerequisites
Before you begin, ensure you have:
- GitHub account with repository access
- AWS VPC with Ubuntu EC2 instances
- SSH key pair (PEM file) for authentication to target hosts
- AppDynamics Smart Agent package
- Target Ubuntu EC2 instances with SSH access
Fork or Clone the Repository
First, get access to the GitHub Actions lab repository:
Repository URL: https://github.com/chambear2809/github-actions-lab
Configure Self-hosted Runner
Your self-hosted runner must be deployed in the same AWS VPC as your target EC2 instances.
Install Runner on EC2 Instance
Launch EC2 instance in your VPC (Ubuntu or Amazon Linux 2)
Navigate to runner settings in your forked repository:
SSH into the runner instance and execute installation commands:
Verify Runner Status
Check that the runner appears as “Idle” (green) in:
Tip
The runner must remain online and idle to pick up workflow jobs. If it shows offline, check the service status: sudo ./svc.sh status
Configure GitHub Secrets
Navigate to: Settings → Secrets and variables → Actions → Secrets
SSH Private Key Secret
This secret contains your SSH private key for accessing target hosts.
- Click “New repository secret”
- Name:
SSH_PRIVATE_KEY - Value: Paste the contents of your PEM file
Example format:
- Click “Add secret”
Important
Never commit SSH keys to your repository! Always use GitHub Secrets for sensitive credentials.
Configure GitHub Variables
Navigate to: Settings → Secrets and variables → Actions → Variables
Deployment Hosts Variable (Required)
This variable contains the list of all target hosts where Smart Agent should be deployed.
- Click “New repository variable”
- Name:
DEPLOYMENT_HOSTS - Value: Enter your target host IPs (one per line)
Format Requirements:
- One IP per line
- No commas
- No spaces
- No extra characters
- Use Unix line endings (LF, not CRLF)
- Click “Add variable”
Optional Variables
These variables are optional and used for Smart Agent service user/group configuration:
SMARTAGENT_USER
- Click “New repository variable”
- Name:
SMARTAGENT_USER - Value: e.g.,
appdynamics - Click “Add variable”
SMARTAGENT_GROUP
- Click “New repository variable”
- Name:
SMARTAGENT_GROUP - Value: e.g.,
appdynamics - Click “Add variable”
Network Configuration
For the lab setup with all EC2 instances in the same VPC and security group:
Security Group Rules
Inbound Rules:
- SSH (port 22) from same security group (source: same SG)
Outbound Rules:
- HTTPS (port 443) to 0.0.0.0/0 (for GitHub API access)
- SSH (port 22) to same security group (for target access)
Network Best Practices
- ✅ Use private IP addresses (172.31.x.x) for
DEPLOYMENT_HOSTS - ✅ Runner and targets in same security group
- ✅ No public IPs needed on target hosts
- ✅ Runner communicates via private network
- ✅ Outbound HTTPS required for GitHub polling
Verify Configuration
Before running workflows, verify your setup:
1. Check Runner Status
- Go to Settings → Actions → Runners
- Verify runner shows as “Idle” (green)
- Check “Last seen” timestamp is recent
2. Test SSH Connectivity
SSH from your runner instance to a target host:
If successful, you should get a shell prompt on the target host.
3. Verify Secrets and Variables
- Go to Settings → Secrets and variables → Actions
- Confirm secrets tab shows:
SSH_PRIVATE_KEY - Confirm variables tab shows:
DEPLOYMENT_HOSTS
4. Check Repository Access
Ensure the runner can access the repository:
You should see: “Listening for Jobs”
Troubleshooting Common Issues
Runner Not Picking Up Jobs
Symptom: Workflows stay in “queued” state
Solution:
- Check runner status:
sudo systemctl status actions.runner.* - Restart runner:
sudo ./svc.sh restart - Verify outbound HTTPS (443) connectivity to GitHub
SSH Connection Failures
Symptom: Workflows fail with “Permission denied” or “Connection refused”
Solution:
Invalid Characters in Hostname
Symptom: Error: “hostname contains invalid characters”
Solution:
- Edit
DEPLOYMENT_HOSTSvariable - Ensure no trailing spaces
- Use Unix line endings (LF, not CRLF)
- One IP per line, no extra characters
Secrets Not Found
Symptom: Error: “Secret SSH_PRIVATE_KEY not found”
Solution:
- Verify secret name exactly matches:
SSH_PRIVATE_KEY - Check secret is in repository secrets (not environment secrets)
- Ensure you have repository admin access
Security Best Practices
Follow these best practices for secure operations:
- ✅ Use GitHub Secrets for all private keys
- ✅ Rotate SSH keys regularly
- ✅ Keep runner in private VPC subnet
- ✅ Restrict runner security group to minimal access
- ✅ Update runner software regularly
- ✅ Enable branch protection rules
- ✅ Use separate keys for different environments
- ✅ Enable audit logging for repository access
Next Steps
With GitHub configured and the runner set up, you’re ready to explore the available workflows and execute your first deployment!