Skip to content

Increase Node Disk

Increase Node Disk #86

name: Increase Node Disk
on:
workflow_dispatch:
inputs:
network:
type: environment
description: "Whether updating a testnet or mainnet node"
default: "mainnet"
required: true
aws_region:
description: "AWS region of EC2 instance to modify"
required: true
instance_id:
description: "The EC2 instance id"
required: true
disk_size:
description: "The amount of diskspace to add (GB)"
default: "50"
required: true
jobs:
increase-disk:
environment: ${{inputs.network}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Hosts Config
id: get-hosts
uses: keithweaver/[email protected]
with:
command: cp
source: ${{vars.S3_ANSIBLE_HOST_FILE}}
destination: ./ansible-hosts
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_KEY }}
aws_region: ${{vars.S3_REGION}}
- name: Run playbook
uses: arillso/action.playbook@master
with:
# Required, playbook filepath
playbook: ./scripts/ansible/aws/ec2-modify-volume-size.yml
inventory: ./ansible-hosts
galaxy_file: ./scripts/ansible/aws/requirements.yml
verbose: 3
extra_vars: "aws_region=${{github.event.inputs.aws_region}} instance_id=${{inputs.instance_id}} aws_secret_key=${{secrets.AWS_SECRET_KEY}} aws_access_key_id=${{secrets.AWS_ACCESS_KEY_ID}} volume_size=${{github.event.inputs.disk_size}} ansible_python_interpreter='/usr/bin/python3'"
- name: Wait for AWS to finish provisioning the disk
run: sleep 30m
shell: bash
- name: Extend file system
id: extend-file-system
uses: nohmad/aws-ssm-send-command-action@master
with:
aws-region: ${{ inputs.aws_region }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
targets: |
[{"Key":"InstanceIds","Values":["${{ inputs.instance_id }}"]}]
document-name: AWS-RunShellScript
parameters: |
{"commands":["sudo growpart /dev/nvme0n1 1", "sudo resize2fs /dev/nvme0n1p1"]}
- name: Get SSM output
id: get-ssm-output
if: steps.extend-file-system.outcome == 'success'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_DEFAULT_REGION: ${{ inputs.aws_region }}
run: |
echo "COMMAND_OUTPUT=$(aws ssm list-command-invocations --command-id ${{ steps.extend-file-system.outputs.command-id }} --details)" >> $GITHUB_ENV
- name: Check SSM output
if: steps.get-ssm-output.outcome == 'success' && contains(env.COMMAND_OUTPUT, 'error')
run: |
echo "Error detected trying to extend the partition."
echo ${{env.COMMAND_OUTPUT}}
exit 1