Skip to content

Commit 0c02fc0

Browse files
authored
Merge branch 'main' into copilot/fix-57
2 parents a0cf3d8 + 9348ef0 commit 0c02fc0

31 files changed

+3238
-20
lines changed

.cline_rules

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# OSVM CLI Project Rules
2+
3+
## CRITICAL: No Custom Scripts
4+
- **NEVER create custom shell scripts, Python scripts, or any standalone scripts in this repository**
5+
- **ALL functionality must be implemented within the osvm binary itself**
6+
- **The only way to execute functionality is through the compiled osvm binary**
7+
- If a feature needs to be added, it must be implemented in the Rust source code and compiled into osvm
8+
9+
## Project Structure
10+
- All code must be in Rust source files under src/
11+
- Use cargo build to compile changes
12+
- Execute features only via ./target/debug/osvm or cargo run
13+
14+
## Examples of what NOT to do:
15+
- ❌ Creating shell scripts (*.sh files)
16+
- ❌ Creating Python scripts (*.py files)
17+
- ❌ Creating any standalone executable scripts
18+
- ❌ Using external tools when osvm can handle it
19+
20+
## Examples of what TO do:
21+
- ✅ Implement features in Rust within src/
22+
- ✅ Use cargo build to compile
23+
- ✅ Run features via osvm binary commands
24+
- ✅ If osvm doesn't have a feature, implement it in the Rust code first
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# SVM Deploy Action
2+
3+
This GitHub Action deploys Solana Virtual Machine (SVM) nodes using the openSVM CLI tool. It abstracts away the complexity of SVM deployments, making it easy to integrate SVM node deployment into your CI/CD pipelines.
4+
5+
## Features
6+
7+
- 🚀 **Simple Integration**: One-step SVM deployment with minimal configuration
8+
- 🔒 **Secure**: Uses GitHub Secrets for sensitive data like SSH keys and Solana keypairs
9+
- 🎯 **Configurable**: Support for different networks, node types, and deployment options
10+
- 📊 **Detailed Logging**: Comprehensive logs for troubleshooting and monitoring
11+
- 🔄 **Flexible**: Supports additional CLI arguments for advanced use cases
12+
13+
## Usage
14+
15+
### Basic Example
16+
17+
```yaml
18+
name: Deploy SVM
19+
20+
on:
21+
push:
22+
branches: [ main ]
23+
24+
jobs:
25+
deploy:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Deploy SVM Node
31+
uses: ./.github/actions/svm-deploy
32+
with:
33+
svm-name: 'my-svm'
34+
35+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
36+
network: 'devnet'
37+
node-type: 'validator'
38+
```
39+
40+
### Advanced Example
41+
42+
```yaml
43+
name: Deploy SVM with Custom Configuration
44+
45+
on:
46+
workflow_dispatch:
47+
inputs:
48+
svm_name:
49+
description: 'SVM name to deploy'
50+
required: true
51+
default: 'my-svm'
52+
target_host:
53+
description: 'Target host for deployment'
54+
required: true
55+
default: '[email protected]'
56+
network:
57+
description: 'Network to deploy on'
58+
required: true
59+
default: 'devnet'
60+
type: choice
61+
options:
62+
- mainnet
63+
- testnet
64+
- devnet
65+
66+
jobs:
67+
deploy:
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Deploy SVM Node
73+
uses: ./.github/actions/svm-deploy
74+
with:
75+
svm-name: ${{ github.event.inputs.svm_name }}
76+
host: ${{ github.event.inputs.target_host }}
77+
network: ${{ github.event.inputs.network }}
78+
node-type: 'validator'
79+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
80+
keypair: ${{ secrets.SOLANA_KEYPAIR }}
81+
rpc-url: ${{ secrets.RPC_URL }}
82+
verbose: true
83+
deploy-args: '--custom-flag value'
84+
```
85+
86+
## Inputs
87+
88+
| Input | Description | Required | Default |
89+
|-------|-------------|----------|---------|
90+
| `svm-name` | Name of the SVM to deploy | ✅ | - |
91+
| `host` | Remote host to deploy to (format: user@host[:port]) | ✅ | - |
92+
| `network` | Target Solana network (mainnet, testnet, devnet) | ❌ | `mainnet` |
93+
| `node-type` | Type of node to deploy (validator, rpc) | ❌ | `validator` |
94+
| `ssh-private-key` | SSH private key for connecting to remote host | ✅ | - |
95+
| `keypair` | Solana keypair JSON content | ❌ | - |
96+
| `rpc-url` | JSON RPC URL for the cluster | ❌ | - |
97+
| `verbose` | Enable verbose logging | ❌ | `false` |
98+
| `deploy-args` | Additional CLI flags for deployment | ❌ | - |
99+
100+
## Outputs
101+
102+
| Output | Description |
103+
|--------|-------------|
104+
| `status` | Deployment status (success or failure) |
105+
| `logs` | Complete deployment logs |
106+
107+
## Secrets Setup
108+
109+
### Required Secrets
110+
111+
1. **SSH_PRIVATE_KEY**: Private SSH key for connecting to your remote host
112+
```bash
113+
# Generate a new SSH key pair
114+
ssh-keygen -t ed25519 -C "github-actions" -f ~/.ssh/github_actions
115+
116+
# Add the private key to GitHub Secrets as SSH_PRIVATE_KEY
117+
cat ~/.ssh/github_actions
118+
119+
# Add the public key to your remote host's authorized_keys
120+
cat ~/.ssh/github_actions.pub >> ~/.ssh/authorized_keys
121+
```
122+
123+
### Optional Secrets
124+
125+
2. **SOLANA_KEYPAIR**: Solana keypair JSON content
126+
```bash
127+
# Generate a new Solana keypair
128+
solana-keygen new --no-bip39-passphrase -o keypair.json
129+
130+
# Add the keypair content to GitHub Secrets as SOLANA_KEYPAIR
131+
cat keypair.json
132+
```
133+
134+
3. **RPC_URL**: Custom RPC endpoint URL
135+
```
136+
# Example RPC URLs
137+
https://api.mainnet-beta.solana.com
138+
https://api.devnet.solana.com
139+
https://api.testnet.solana.com
140+
```
141+
142+
## Security Considerations
143+
144+
- **Never commit private keys or secrets** to your repository
145+
- Use GitHub Secrets for all sensitive data
146+
- Ensure your SSH private key has appropriate permissions (600)
147+
- Consider using dedicated keypairs for CI/CD deployments
148+
- Regularly rotate your SSH keys and Solana keypairs
149+
150+
## Troubleshooting
151+
152+
### Common Issues
153+
154+
1. **SSH Connection Failed**
155+
- Verify the SSH private key is correct
156+
- Check that the public key is added to the remote host's authorized_keys
157+
- Ensure the host format is correct (user@host[:port])
158+
159+
2. **SVM Installation Failed**
160+
- Check the verbose logs for detailed error messages
161+
- Verify the SVM name is correct and available
162+
- Ensure the remote host meets system requirements
163+
164+
3. **Network Issues**
165+
- Verify the network parameter is correct (mainnet, testnet, devnet)
166+
- Check if the specified RPC URL is accessible
167+
- Ensure firewall rules allow the necessary connections
168+
169+
### Getting Help
170+
171+
If you encounter issues:
172+
173+
1. Enable verbose logging by setting `verbose: true`
174+
2. Check the action logs for detailed error messages
175+
3. Verify your secrets are correctly configured
176+
4. Consult the [openSVM CLI documentation](https://github.com/openSVM/osvm-cli)
177+
178+
## Examples Repository
179+
180+
For more examples and use cases, check out the [examples directory](../../../examples/) in the main repository.
181+
182+
## Contributing
183+
184+
Contributions are welcome! Please:
185+
186+
1. Fork the repository
187+
2. Create a feature branch
188+
3. Make your changes
189+
4. Add tests if applicable
190+
5. Submit a pull request
191+
192+
## License
193+
194+
This action is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: 'Deploy SVM'
2+
description: 'Deploy Solana Virtual Machine nodes using the OSVM CLI'
3+
author: 'openSVM'
4+
branding:
5+
icon: 'upload-cloud'
6+
color: 'purple'
7+
8+
inputs:
9+
svm-name:
10+
description: 'Name of the SVM to deploy'
11+
required: true
12+
host:
13+
description: 'Remote host to deploy to (format: user@host[:port])'
14+
required: true
15+
network:
16+
description: 'Target Solana network'
17+
required: false
18+
default: 'mainnet'
19+
node-type:
20+
description: 'Type of node to deploy (validator or rpc)'
21+
required: false
22+
default: 'validator'
23+
ssh-private-key:
24+
description: 'SSH private key for connecting to remote host'
25+
required: true
26+
keypair:
27+
description: 'Solana keypair JSON content'
28+
required: false
29+
rpc-url:
30+
description: 'JSON RPC URL for the cluster'
31+
required: false
32+
verbose:
33+
description: 'Enable verbose logging'
34+
required: false
35+
default: 'false'
36+
deploy-args:
37+
description: 'Additional CLI flags for deployment'
38+
required: false
39+
default: ''
40+
41+
outputs:
42+
status:
43+
description: 'Deployment status (success or failure)'
44+
value: ${{ steps.deploy.outputs.status }}
45+
logs:
46+
description: 'Deployment logs'
47+
value: ${{ steps.deploy.outputs.logs }}
48+
49+
runs:
50+
using: 'composite'
51+
steps:
52+
- name: Setup SSH key
53+
shell: bash
54+
run: |
55+
mkdir -p ~/.ssh
56+
echo "${{ inputs.ssh-private-key }}" > ~/.ssh/id_rsa
57+
chmod 600 ~/.ssh/id_rsa
58+
ssh-keyscan -H $(echo "${{ inputs.host }}" | cut -d'@' -f2 | cut -d':' -f1) >> ~/.ssh/known_hosts
59+
60+
- name: Setup Solana keypair
61+
shell: bash
62+
if: inputs.keypair != ''
63+
run: |
64+
mkdir -p ~/.config/solana
65+
echo "${{ inputs.keypair }}" > ~/.config/solana/id.json
66+
chmod 600 ~/.config/solana/id.json
67+
68+
- name: Install OSVM CLI
69+
shell: bash
70+
run: |
71+
# Check if osvm binary is already available
72+
if ! command -v osvm &> /dev/null; then
73+
echo "Installing OSVM CLI..."
74+
# Download and install the latest release
75+
OSVM_VERSION=$(curl -s https://api.github.com/repos/openSVM/osvm-cli/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
76+
if [ -z "$OSVM_VERSION" ]; then
77+
echo "Warning: Could not determine latest version, using main branch"
78+
# Build from source if no release is available
79+
if [ ! -d "/tmp/osvm-cli" ]; then
80+
git clone https://github.com/openSVM/osvm-cli.git /tmp/osvm-cli
81+
fi
82+
cd /tmp/osvm-cli
83+
cargo build --release
84+
sudo cp target/release/osvm /usr/local/bin/osvm
85+
else
86+
echo "Installing OSVM CLI version $OSVM_VERSION"
87+
wget -O /tmp/osvm "https://github.com/openSVM/osvm-cli/releases/download/$OSVM_VERSION/osvm-linux-x86_64" 2>/dev/null || {
88+
echo "Binary release not available, building from source..."
89+
if [ ! -d "/tmp/osvm-cli" ]; then
90+
git clone https://github.com/openSVM/osvm-cli.git /tmp/osvm-cli
91+
fi
92+
cd /tmp/osvm-cli
93+
cargo build --release
94+
sudo cp target/release/osvm /usr/local/bin/osvm
95+
}
96+
if [ -f "/tmp/osvm" ]; then
97+
chmod +x /tmp/osvm
98+
sudo mv /tmp/osvm /usr/local/bin/osvm
99+
fi
100+
fi
101+
fi
102+
103+
# Verify installation
104+
osvm --version
105+
106+
- name: Deploy SVM
107+
id: deploy
108+
shell: bash
109+
run: |
110+
set -e
111+
112+
echo "::group::Deploying SVM"
113+
114+
# Build command
115+
CMD="osvm svm install"
116+
CMD="$CMD --host ${{ inputs.host }}"
117+
118+
if [ "${{ inputs.rpc-url }}" != "" ]; then
119+
CMD="$CMD --url ${{ inputs.rpc-url }}"
120+
fi
121+
122+
if [ "${{ inputs.keypair }}" != "" ]; then
123+
CMD="$CMD --keypair ~/.config/solana/id.json"
124+
fi
125+
126+
if [ "${{ inputs.verbose }}" == "true" ]; then
127+
CMD="$CMD -v"
128+
fi
129+
130+
# Add any additional deployment arguments
131+
if [ "${{ inputs.deploy-args }}" != "" ]; then
132+
CMD="$CMD ${{ inputs.deploy-args }}"
133+
fi
134+
135+
# Add SVM name at the end
136+
CMD="$CMD ${{ inputs.svm-name }}"
137+
138+
echo "Executing: $CMD"
139+
140+
# Execute the deployment
141+
if OUTPUT=$(eval $CMD 2>&1); then
142+
echo "status=success" >> $GITHUB_OUTPUT
143+
echo "logs<<EOF" >> $GITHUB_OUTPUT
144+
echo "$OUTPUT" >> $GITHUB_OUTPUT
145+
echo "EOF" >> $GITHUB_OUTPUT
146+
echo "✅ SVM deployment completed successfully"
147+
echo "$OUTPUT"
148+
else
149+
echo "status=failure" >> $GITHUB_OUTPUT
150+
echo "logs<<EOF" >> $GITHUB_OUTPUT
151+
echo "$OUTPUT" >> $GITHUB_OUTPUT
152+
echo "EOF" >> $GITHUB_OUTPUT
153+
echo "❌ SVM deployment failed"
154+
echo "$OUTPUT"
155+
exit 1
156+
fi
157+
158+
echo "::endgroup::"
159+
160+
- name: Cleanup
161+
shell: bash
162+
if: always()
163+
run: |
164+
# Clean up SSH key and keypair
165+
rm -f ~/.ssh/id_rsa
166+
rm -f ~/.config/solana/id.json

0 commit comments

Comments
 (0)