|
| 1 | +name: 'iota-sandbox-setup' |
| 2 | +description: 'Setup IOTA Sandbox' |
| 3 | +inputs: |
| 4 | + version: |
| 5 | + description: 'Sandbox Version to use' |
| 6 | + required: false |
| 7 | + default: 'latest' |
| 8 | + branch: |
| 9 | + description: 'Branch/tag/commit to use' |
| 10 | + required: false |
| 11 | + protocol_parameters: |
| 12 | + description: 'Path to custom protocol parameters file' |
| 13 | + required: false |
| 14 | + milestone_interval: |
| 15 | + description: 'Custom milestone interval' |
| 16 | + required: false |
| 17 | +runs: |
| 18 | + using: "composite" |
| 19 | + steps: |
| 20 | + - name: Check if a faucet profile is enabled |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + IFS=',' read -ra PROFILES <<< "${{ env.COMPOSE_PROFILES }}" # Split by , |
| 24 | + FAUCET_ENABLED=false |
| 25 | + for i in "${PROFILES[@]}"; do |
| 26 | + i=$(echo "$i" | xargs) # Trim leading and trailing whitespaces |
| 27 | + if [[ "$i" == "inx" || "$i" == "inx-faucet" ]]; then # Check if inx or inx-faucet profile is enabled |
| 28 | + FAUCET_ENABLED=true |
| 29 | + break |
| 30 | + fi |
| 31 | + done |
| 32 | + echo "FAUCET_ENABLED=$FAUCET_ENABLED" >> "$GITHUB_ENV" |
| 33 | + - name: Setup iota sandbox using release version |
| 34 | + shell: bash |
| 35 | + if: ${{ inputs.version && !inputs.branch }} |
| 36 | + run: | |
| 37 | + mkdir iota-sandbox |
| 38 | + cd iota-sandbox |
| 39 | + mkdir sandbox |
| 40 | + cd sandbox |
| 41 | + # Use the output of https://api.github.com/repos/iotaledger/iota-sandbox/releases/ |
| 42 | + if [[ "${{ inputs.version }}" == "latest" ]]; then |
| 43 | + DOWNLOAD_URL=$(curl "https://api.github.com/repos/iotaledger/iota-sandbox/releases/latest" | jq -r '.assets[] | select(.name | contains("iota_sandbox")) | .browser_download_url') |
| 44 | + else |
| 45 | + DOWNLOAD_URL=$(curl "https://api.github.com/repos/iotaledger/iota-sandbox/releases/tags/${{ inputs.version }}" | jq -r '.assets[] | select(.name | contains("iota_sandbox")) | .browser_download_url') |
| 46 | + fi |
| 47 | + echo "Downloading sandbox from $DOWNLOAD_URL" |
| 48 | + curl -L -o iota_sandbox.tar.gz $DOWNLOAD_URL |
| 49 | + tar -xf iota_sandbox.tar.gz |
| 50 | + - name: Setup iota sandbox using gitish version |
| 51 | + shell: bash |
| 52 | + if: ${{ inputs.branch }} |
| 53 | + run: | |
| 54 | + git clone https://github.com/iotaledger/iota-sandbox --branch ${{ inputs.branch }} |
| 55 | + - name: Overwrite protocol parameters |
| 56 | + shell: bash |
| 57 | + if: ${{ inputs.protocol_parameters }} |
| 58 | + run: | |
| 59 | + cp -f ${{ inputs.protocol_parameters }} iota-sandbox/sandbox/protocol_parameters.json |
| 60 | + - name: Change milestone interval |
| 61 | + working-directory: iota-sandbox/sandbox |
| 62 | + shell: bash |
| 63 | + if: ${{ inputs.milestone_interval }} |
| 64 | + run: | |
| 65 | + yq eval '.services.inx-coordinator.command += "--coordinator.interval=${{ inputs.milestone_interval }}"' docker-compose.yml > tmp.yml && mv tmp.yml docker-compose.yml |
| 66 | + - name: Bootstrap and start sandbox |
| 67 | + working-directory: iota-sandbox/sandbox |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + sudo ./bootstrap.sh |
| 71 | + docker compose up -d |
| 72 | + - name: Wait for faucet to start |
| 73 | + if: ${{ env.FAUCET_ENABLED == 'true' }} |
| 74 | + shell: bash |
| 75 | + run: wget -qO- https://raw.githubusercontent.com/iotaledger/wait-for/$WAIT_FOR_VERSION/wait-for | sh -s -- -t 60 http://localhost/faucet/api/info -- echo "Faucet is up" |
| 76 | + env: |
| 77 | + WAIT_FOR_VERSION: d48601a8a90c3d22fade68d09b4240739fb44a46 # v2.2.4 |
0 commit comments