Remove comments from json #35
Workflow file for this run
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
# Deploy the miden node for testnet and devnet. | |
# | |
# testnet is deployed manually using `workflow_dispatch`, and devnet is deployed | |
# on every push to the `next` branch. | |
# | |
# All previous node data is removed during deployment i.e. an update restarts the | |
# node from genesis again. | |
name: Node deployment fix | |
on: | |
push: | |
branches: | |
- Fix-deployment-workflow | |
workflow_dispatch: | |
# workflow_dispatch: | |
# inputs: | |
# network: | |
# required: true | |
# default: 'devnet' | |
# type: choice | |
# options: | |
# - devnet | |
# # temporarily disabled until we are happy this works on devnet | |
# # - testnet | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Configure AWS credentials based on network. | |
- name: Checkout Code Repository | |
uses: actions/checkout@v3 | |
# Configure the `NETWORK` env variable based on the trigger type. | |
# | |
# This is then used by subsequent steps to switch on devnet | testnet, | |
# instead of switching on trigger type which is less readible. | |
- name: Configure for testnet | |
if: ${{ inputs.network == 'testnet' }} | |
env: | |
INSTANCE_ID: ${{ secrets.TESTNET_INSTANCE_ID }} | |
run: echo "NETWORK=testnet" >> $GITHUB_ENV | |
- name: Configure for devnet | |
if: ${{ inputs.network == 'devnet' }} | |
env: | |
INSTANCE_ID: ${{ secrets.DEVNET_INSTANCE_ID }} | |
run: echo "NETWORK=devnet" >> $GITHUB_ENV | |
# - name: Configure testnet AWS credentials | |
# if: env.NETWORK == 'testnet' | |
# uses: aws-actions/configure-aws-credentials@v1 | |
# with: | |
# aws-region: us-west-1 | |
# role-to-assume: arn:aws:iam::211125515935:role/midentest-GithubActionsRole | |
# role-session-name: GithubActionsSession | |
- name: Configure devnet AWS credentials | |
# if: env.NETWORK == 'devnet' | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: eu-west-1 | |
role-to-assume: arn:aws:iam::657556092833:role/midendev-GithubActionsRole | |
role-session-name: GithubActionsSession | |
- name: Stop services | |
id: stop_services | |
run: | | |
COMMAND_ID=$(aws ssm send-command \ | |
--instance-ids i-0d50212756bccc552 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters '{"commands":["sudo systemctl stop miden-node", "sudo systemctl stop miden-faucet"]}' \ | |
--output text \ | |
--query "Command.CommandId") | |
echo "command_id=$COMMAND_ID" >> $GITHUB_OUTPUT | |
- name: Check stop services command status and retrieve output | |
run: | | |
sleep 5 | |
STATUS=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.stop_services.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].Status" \ | |
--output text) | |
echo "Command Status: $STATUS" | |
OUTPUT=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.stop_services.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
--output text) | |
echo "Command Output: $OUTPUT" | |
if [ "$STATUS" != "Success" ]; then | |
echo "Command failed with status: $STATUS" | |
exit 1 | |
fi | |
- name: Install prerequisites | |
id: install_prereq | |
run: | | |
COMMAND_ID=$(aws ssm send-command \ | |
--instance-ids i-0d50212756bccc552 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters '{"commands":[ | |
"sudo apt-get update -y", | |
"sudo apt-get install -y git gcc openssl libbz2-dev libffi7 make cargo", | |
"sudo apt install -y build-essential", | |
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y", | |
"source $HOME/.cargo/env", | |
"rustup update", | |
"sudo apt-get install -y clang cmake" | |
]}' \ | |
--output text \ | |
--query "Command.CommandId") | |
echo "command_id=$COMMAND_ID" >> $GITHUB_OUTPUT | |
- name: Poll command status and retrieve live logs from install prereqs | |
run: | | |
while true; do | |
STATUS=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.install_prereq.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].Status" \ | |
--output text) | |
echo "Command Status: $STATUS" | |
OUTPUT=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.install_prereq.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
--output text) | |
echo "Command Output: $OUTPUT" | |
if [ "$STATUS" == "Success" ]; then | |
echo "Command completed successfully." | |
break | |
elif [ "$STATUS" == "Failed" ] || [ "$STATUS" == "Cancelled" ]; then | |
echo "Command failed with status: $STATUS" | |
exit 1 | |
else | |
sleep 30 # Wait for 30 seconds before checking again | |
fi | |
done | |
- name: Install devnet | |
id: install_devnet | |
run: | | |
COMMAND_ID=$(aws ssm send-command \ | |
--instance-ids i-0d50212756bccc552 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters '{"commands":[ | |
"cd /home/ubuntu", | |
"curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y", | |
"source $HOME/.cargo/env", | |
"rustup update stable", | |
"rustc --version", | |
"cargo install --git https://github.com/0xPolygonMiden/miden-node miden-node --branch next --bin miden-node --locked --features testing", | |
"cargo install --git https://github.com/0xPolygonMiden/miden-node miden-faucet --branch next --bin miden-faucet --locked --features testing" | |
]}' \ | |
--output text \ | |
--query "Command.CommandId") | |
echo "command_id=$COMMAND_ID" >> $GITHUB_OUTPUT | |
- name: Poll command status and retrieve live logs | |
run: | | |
while true; do | |
STATUS=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.install_devnet.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].Status" \ | |
--output text) | |
echo "Command Status: $STATUS" | |
OUTPUT=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.install_devnet.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
--output text) | |
echo "Command Output: $OUTPUT" | |
if [ "$STATUS" == "Success" ]; then | |
echo "Command completed successfully." | |
break | |
elif [ "$STATUS" == "Failed" ] || [ "$STATUS" == "Cancelled" ]; then | |
echo "Command failed with status: $STATUS" | |
exit 1 | |
else | |
sleep 30 # Wait for 30 seconds before checking again | |
fi | |
done | |
# - name: Check install devnet command status and retrieve output | |
# run: | | |
# sleep 1800 | |
# STATUS=$(aws ssm list-command-invocations \ | |
# --command-id ${{ steps.install_devnet.outputs.command_id }} \ | |
# --details \ | |
# --query "CommandInvocations[0].Status" \ | |
# --output text) | |
# echo "Command Status: $STATUS" | |
# OUTPUT=$(aws ssm list-command-invocations \ | |
# --command-id ${{ steps.install_devnet.outputs.command_id }} \ | |
# --details \ | |
# --query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
# --output text) | |
# echo "Command Output: $OUTPUT" | |
# if [ "$STATUS" != "Success" ]; then | |
# echo "Command failed with status: $STATUS" | |
# exit 1 | |
# fi | |
- name: Configure devnet | |
id: configure_devnet | |
run: | | |
COMMAND_ID=$(aws ssm send-command \ | |
--instance-ids i-0d50212756bccc552 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters '{"commands":[ | |
"rm -rf ~/miden-node; mkdir ~/miden-node", | |
"rm -rf ~/miden-faucet; mkdir ~/miden-faucet", | |
"miden-node init -c ~/miden-node/miden-node.toml -g ~/miden-node/genesis.toml", | |
"miden-node make-genesis -i ~/miden-node/genesis.toml -o ~/miden-node/genesis.dat", | |
"miden-faucet init -c ~/miden-faucet/miden-faucet.toml", | |
"cat > /etc/systemd/system/miden-node.service << 'END_OF_CAT' ... END_OF_CAT", | |
"cat > /etc/systemd/system/miden-facuet.service << 'END_OF_CAT' ... END_OF_CAT" | |
]}' \ | |
--output text \ | |
--query "Command.CommandId") | |
echo "command_id=$COMMAND_ID" >> $GITHUB_OUTPUT | |
- name: Check configure devnet command status and retrieve output | |
run: | | |
sleep 50 | |
STATUS=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.configure_devnet.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].Status" \ | |
--output text) | |
echo "Command Status: $STATUS" | |
OUTPUT=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.configure_devnet.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
--output text) | |
echo "Command Output: $OUTPUT" | |
if [ "$STATUS" != "Success" ]; then | |
echo "Command failed with status: $STATUS" | |
exit 1 | |
fi | |
- name: Start services | |
id: start_services | |
run: | | |
COMMAND_ID=$(aws ssm send-command \ | |
--instance-ids i-0d50212756bccc552 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters '{"commands":[ | |
"sudo systemctl daemon-reload", | |
"sudo systemctl enable miden-node", | |
"sudo systemctl enable miden-faucet", | |
"sudo systemctl start miden-node", | |
"sleep 5", | |
"sudo systemctl start miden-faucet" | |
]}' \ | |
--output text \ | |
--query "Command.CommandId") | |
echo "command_id=$COMMAND_ID" >> $GITHUB_OUTPUT | |
- name: Check Start services command status and retrieve output | |
run: | | |
sleep 10 | |
STATUS=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.start_services.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].Status" \ | |
--output text) | |
echo "Command Status: $STATUS" | |
OUTPUT=$(aws ssm list-command-invocations \ | |
--command-id ${{ steps.start_services.outputs.command_id }} \ | |
--details \ | |
--query "CommandInvocations[0].CommandPlugins[0].Output" \ | |
--output text) | |
echo "Command Output: $OUTPUT" | |
if [ "$STATUS" != "Success" ]; then | |
echo "Command failed with status: $STATUS" | |
exit 1 | |
fi |