-
Notifications
You must be signed in to change notification settings - Fork 36
49 lines (39 loc) · 1.73 KB
/
check-staging-deployer-balance.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Checks that the balance of the Solana public key
# associated with the UPGRADE_AUTHORITY_KEYPAIR_STAGING is greater than
# the estimated balance required to deploy a program.
name: Check Staging Deployer Balance
on:
pull_request:
branches:
- main
paths:
- 'programs/squads_multisig_program/**'
jobs:
check-balance:
if: contains(github.event.pull_request.labels.*.name, 'deploy-staging')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Solana
uses: ./.github/actions/setup-solana/
- name: Check Solana Balance
env:
UPGRADE_AUTHORITY_KEYPAIR: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR_STAGING }}
RPC_URL: ${{ secrets.RPC_URL_MAINNET }}
run: |
# Write the keypair to a file so it can be used with solana-keygen
echo $UPGRADE_AUTHORITY_KEYPAIR > ./upgrade-authority.json && chmod 600 ./upgrade-authority.json
# Extract the public key from the keypair file
PUBLIC_KEY=$(solana-keygen pubkey ./upgrade-authority.json)
# Remove the keypair file
rm ./upgrade-authority.json
# Fetch the balance of the public key
BALANCE=$(solana balance $PUBLIC_KEY --url $RPC_URL | awk '{print $1}')
MIN_BALANCE=10
# Check if the balance is less than the minimum balance using floating point comparison with `bc`
if (( $(echo "$BALANCE < $MIN_BALANCE" | bc -l) )); then
echo "Balance of $PUBLIC_KEY is $BALANCE, which is less than the minimum balance of $MIN_BALANCE"
exit 1
fi
echo "Balance of $PUBLIC_KEY is $BALANCE SOL"