Skip to content

Commit 397e4c7

Browse files
authored
Merge pull request #48 from synonymdev/regtest-mine
Regtest mine workflow
2 parents e3f4cdc + a794bd6 commit 397e4c7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/regtest-mine.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Regtest Mine Blocks
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # 2 AM UTC daily
6+
workflow_dispatch:
7+
inputs:
8+
blocktank_server:
9+
description: Blocktank base URL
10+
required: true
11+
default: 'https://api.stag0.blocktank.to/blocktank/api/v2'
12+
block_count:
13+
description: Number of regtest blocks to mine
14+
required: true
15+
default: '1'
16+
17+
jobs:
18+
mine:
19+
runs-on: ubuntu-latest
20+
env:
21+
BLOCK_COUNT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.block_count || '1' }}
22+
BLOCKTANK_SERVER: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.blocktank_server || 'https://api.stag0.blocktank.to/blocktank/api/v2' }}
23+
steps:
24+
- name: Validate params
25+
run: |
26+
if [[ -z "${BLOCK_COUNT}" ]]; then
27+
echo "BLOCK_COUNT is empty" >&2
28+
exit 1
29+
fi
30+
if ! [[ "${BLOCK_COUNT}" =~ ^[0-9]+$ ]]; then
31+
echo "BLOCK_COUNT must be a positive integer: ${BLOCK_COUNT}" >&2
32+
exit 1
33+
fi
34+
if [[ "${BLOCK_COUNT}" -eq 0 ]]; then
35+
echo "BLOCK_COUNT must be greater than zero" >&2
36+
exit 1
37+
fi
38+
if [[ -z "${BLOCKTANK_SERVER}" ]]; then
39+
echo "BLOCKTANK_SERVER is empty" >&2
40+
exit 1
41+
fi
42+
- name: Mine regtest blocks
43+
run: |
44+
echo "Mining ${BLOCK_COUNT} block(s) on regtest..."
45+
curl --fail --silent --show-error \
46+
-X POST \
47+
"${BLOCKTANK_SERVER}/regtest/chain/mine" \
48+
-H 'Content-Type: application/json' \
49+
-d "{\"count\": ${BLOCK_COUNT}}"

0 commit comments

Comments
 (0)