1+ name : Deploy Devnet From Scratch
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ devnet_name :
7+ description : " Devnet name (e.g., devnet-latte, devnet-mocha)"
8+ required : true
9+ type : string
10+ default : " devnet-latte"
11+ masternode_amd_count :
12+ description : " Number of AMD masternodes"
13+ required : false
14+ type : number
15+ default : 1
16+ masternode_arm_count :
17+ description : " Number of ARM masternodes"
18+ required : false
19+ type : number
20+ default : 1
21+ hp_masternode_amd_count :
22+ description : " Number of HP AMD masternodes"
23+ required : false
24+ type : number
25+ default : 5
26+ hp_masternode_arm_count :
27+ description : " Number of HP ARM masternodes"
28+ required : false
29+ type : number
30+ default : 5
31+ platform_version :
32+ description : " Platform version to deploy (e.g., 2.0.0-rc.16)"
33+ required : true
34+ type : string
35+ default : " 2.0.0-rc.16"
36+ dashd_version :
37+ description : " Dash Core version (e.g., 22.1.0)"
38+ required : true
39+ type : string
40+ default : " 22.1.0"
41+ main_domain :
42+ description : " Main domain for the network"
43+ required : false
44+ type : string
45+ default : " networks.dash.org"
46+ create_eip :
47+ description : " Create Elastic IPs for nodes"
48+ required : false
49+ type : boolean
50+ default : false
51+
52+ jobs :
53+ deploy :
54+ name : Deploy Devnet
55+ runs-on : ubuntu-latest
56+
57+ steps :
58+ - name : Checkout dash-network-deploy
59+ uses : actions/checkout@v4
60+
61+ - name : Set up Node.js
62+ uses : actions/setup-node@v4
63+ with :
64+ node-version : ' 20'
65+
66+ - name : Install dependencies
67+ run : |
68+ npm ci
69+ python -m pip install --upgrade pip
70+ pip install ansible
71+
72+ - name : Install Ansible roles
73+ run : |
74+ ansible-galaxy install -r ansible/requirements.yml
75+
76+ - name : Set up SSH Keys
77+ run : |
78+ mkdir -p ~/.ssh
79+
80+ # GitHub deploy key for cloning configs
81+ echo "${{ secrets.EVO_APP_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
82+ chmod 600 ~/.ssh/id_ed25519
83+
84+ # Server SSH key for connecting to nodes
85+ echo "${{ secrets.DEPLOY_SERVER_KEY }}" > ~/.ssh/id_rsa
86+ chmod 600 ~/.ssh/id_rsa
87+
88+ # SSH config
89+ cat > ~/.ssh/config << 'EOL'
90+ Host github.com
91+ IdentityFile ~/.ssh/id_ed25519
92+ StrictHostKeyChecking no
93+
94+ Host *
95+ IdentityFile ~/.ssh/id_rsa
96+ User ubuntu
97+ StrictHostKeyChecking no
98+ UserKnownHostsFile=/dev/null
99+ EOL
100+
101+ chmod 600 ~/.ssh/config
102+
103+ # Clone network configs
104+ - name : Clone network configs
105+ run : |
106+ rm -rf networks
107+ git clone [email protected] :dashpay/dash-network-configs.git networks 108+
109+ # Generate network configuration using bin/generate
110+ - name : Generate network configuration
111+ run : |
112+ # Generate the configs using the official tool
113+ ./bin/generate ${{ github.event.inputs.devnet_name }} \
114+ ${{ github.event.inputs.masternode_amd_count }} \
115+ ${{ github.event.inputs.masternode_arm_count }} \
116+ ${{ github.event.inputs.hp_masternode_amd_count }} \
117+ ${{ github.event.inputs.hp_masternode_arm_count }}
118+
119+ # Update the generated config with the correct versions and domain
120+ sed -i "s/dashmate_version: .*/dashmate_version: ${{ github.event.inputs.platform_version }}/" networks/${{ github.event.inputs.devnet_name }}.yml
121+ sed -i "s/drive_image: dashpay\/drive:[^ ]*/drive_image: dashpay\/drive:${{ github.event.inputs.platform_version }}/" networks/${{ github.event.inputs.devnet_name }}.yml
122+ sed -i "s/dapi_image: dashpay\/dapi:[^ ]*/dapi_image: dashpay\/dapi:${{ github.event.inputs.platform_version }}/" networks/${{ github.event.inputs.devnet_name }}.yml
123+ sed -i "s/dashd_image: dashpay\/dashd:[^ ]*/dashd_image: dashpay\/dashd:${{ github.event.inputs.dashd_version }}/" networks/${{ github.event.inputs.devnet_name }}.yml
124+ sed -i "s/main_domain: .*/main_domain: ${{ github.event.inputs.main_domain }}/" networks/${{ github.event.inputs.devnet_name }}.yml
125+
126+ # Update tfvars with domain and EIP settings
127+ sed -i "s/main_domain = .*/main_domain = \"${{ github.event.inputs.main_domain }}\"/" networks/${{ github.event.inputs.devnet_name }}.tfvars
128+ sed -i "s/create_eip = .*/create_eip = ${{ github.event.inputs.create_eip }}/" networks/${{ github.event.inputs.devnet_name }}.tfvars
129+
130+ echo "Generated network config:"
131+ head -20 networks/${{ github.event.inputs.devnet_name }}.yml
132+ echo ""
133+ echo "Generated terraform config:"
134+ cat networks/${{ github.event.inputs.devnet_name }}.tfvars
135+
136+ # Configure AWS credentials
137+ - name : Configure AWS credentials
138+ uses : aws-actions/configure-aws-credentials@v4
139+ with :
140+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
141+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
142+ aws-region : us-west-2
143+
144+ # Run Terraform deployment using bin/deploy
145+ - name : Run Terraform deployment
146+ run : |
147+ ./bin/deploy -i --github ${{ github.event.inputs.devnet_name }}
148+
149+ # Wait for instances to be ready
150+ - name : Wait for instances to be ready
151+ run : |
152+ echo "Waiting 60 seconds for instances to fully initialize..."
153+ sleep 60
154+
155+ # Run initial Ansible deployment
156+ - name : Run initial Ansible deployment
157+ env :
158+ ANSIBLE_HOST_KEY_CHECKING : " false"
159+ run : |
160+ ./bin/deploy -p ${{ github.event.inputs.devnet_name }}
161+
162+ # Commit and push network configuration
163+ - name : Commit and push network configuration
164+ run : |
165+ cd networks
166+ git config user.name "GitHub Actions"
167+ git config user.email "[email protected] " 168+
169+ git add ${{ github.event.inputs.devnet_name }}.yml ${{ github.event.inputs.devnet_name }}.tfvars ${{ github.event.inputs.devnet_name }}.inventory
170+
171+ if git diff --cached --quiet; then
172+ echo "No changes to commit"
173+ else
174+ git commit -m "Deploy ${{ github.event.inputs.devnet_name }} with platform ${{ github.event.inputs.platform_version }}
175+
176+ 🤖 Generated with [GitHub Actions](https://github.com/dashpay/dash-network-deploy/actions)
177+
178+ Co-Authored-By: GitHub Actions <[email protected] >" 179+ git push origin main
180+ fi
181+
182+ # Output deployment information
183+ - name : Output deployment information
184+ run : |
185+ echo "## Deployment Summary"
186+ echo "Network: ${{ github.event.inputs.devnet_name }}"
187+ echo "Platform Version: ${{ github.event.inputs.platform_version }}"
188+ echo "Dash Core Version: ${{ github.event.inputs.dashd_version }}"
189+ echo "Domain: ${{ github.event.inputs.main_domain }}"
190+ echo ""
191+ echo "## Node Counts"
192+ echo "Masternodes (AMD): ${{ github.event.inputs.masternode_amd_count }}"
193+ echo "Masternodes (ARM): ${{ github.event.inputs.masternode_arm_count }}"
194+ echo "HP Masternodes (AMD): ${{ github.event.inputs.hp_masternode_amd_count }}"
195+ echo "HP Masternodes (ARM): ${{ github.event.inputs.hp_masternode_arm_count }}"
196+ echo ""
197+ echo "## Services"
198+ cd terraform/aws
199+ terraform output -raw services_output || echo "Services output not available"
0 commit comments