Skip to content

Commit cf73888

Browse files
authored
Simplify docker container params (#4)
1 parent aa5b2eb commit cf73888

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

README.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# anchor-build
22

3-
Docker image for building Anchor programs.
3+
Docker image and GitHub Actions step for building Anchor/Solana programs.
44

55
### Usage
66

77
No inputs are required.
88

99
```yaml
10-
- uses: wjthieme/anchor-build@v1
10+
- uses: wjthieme/anchor-build@v2
1111
```
1212
1313
#### Run a different command
1414
1515
By default, `anchor build` is run. You can specify a different command with the `run` input.
1616

1717
```yaml
18-
- uses: wjthieme/anchor-build@v1
18+
- uses: wjthieme/anchor-build@v2
1919
with:
2020
run: "cargo build-sbf"
2121
```
@@ -25,7 +25,7 @@ By default, `anchor build` is run. You can specify a different command with the
2525
By default, the latest version of Anchor is used. You can specify a different version with the `anchor-version` input.
2626

2727
```yaml
28-
- uses: wjthieme/anchor-build@v1
28+
- uses: wjthieme/anchor-build@v2
2929
with:
3030
anchor-version: "v0.29.0"
3131
```
@@ -35,15 +35,7 @@ By default, the latest version of Anchor is used. You can specify a different ve
3535
By default, you'll get a generated keypair to which 1 SOL is airdropped (devnet only). If you want to use your own keypair, you can supply it with the `solana-key` input.
3636

3737
```yaml
38-
- uses: wjthieme/anchor-build@v1
38+
- uses: wjthieme/anchor-build@v2
3939
with:
4040
solana-key: ${{ secrets.SOLANA_PRIVATE_KEY }}
4141
```
42-
43-
### Local Testing
44-
45-
Install `docker` and `act` and run:
46-
47-
```sh
48-
act workflow_dispatch
49-
```

action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ branding:
66
color: blue
77

88
inputs:
9-
solana-key:
10-
description: 'The private key to use for the solana sdk.'
11-
required: false
9+
run:
10+
description: 'The command(s) to run.'
11+
default: 'anchor build'
1212
solana-cluster:
1313
description: 'The cluster to use for the solana sdk.'
1414
required: false
1515
default: 'devnet'
16+
solana-key:
17+
description: 'The private key to use for the solana sdk.'
18+
required: false
1619
anchor-version:
1720
description: 'The version of anchor to use.'
1821
default: 'latest'
19-
run:
20-
description: 'The command(s) to run.'
21-
default: 'anchor build'
2222

2323
runs:
2424
using: "docker"
2525
image: "ghcr.io/wjthieme/anchor-build:${{ inputs.anchor-version }}"
2626
args:
27-
- ${{ inputs.solana-key }}
28-
- ${{ inputs.solana-cluster }}
2927
- ${{ inputs.run }}
28+
- ${{ inputs.solana-cluster }}
29+
- ${{ inputs.solana-key }}

entrypoint.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
#!/bin/bash
22
set -xeo pipefail
33

4+
# Set default network to devnet if $2 is empty or not defined
5+
if [ -z "$2" ]; then
6+
NETWORK="devnet"
7+
else
8+
NETWORK="$2"
9+
fi
10+
411
# Configure Solana
5-
solana config set --url "$2"
12+
solana config set --url "$NETWORK"
613

714
# Configure Solana Key
8-
if [ -z "$1" ]; then
15+
if [ -z "$3" ]; then
916
solana-keygen new --no-bip39-passphrase
1017
else
11-
echo "$1" > ~/.config/solana/id.json
18+
echo "$3" > ~/.config/solana/id.json
1219
fi
1320

1421
# Airdrop Solana if on devnet
15-
if [ "$2" == "devnet" ]; then
22+
if [ "$NETWORK" == "devnet" ]; then
1623
solana airdrop 1 || true
1724
fi
1825

1926
# Run the provided commands
20-
eval "$3"
27+
eval "$1"

0 commit comments

Comments
 (0)