-
Notifications
You must be signed in to change notification settings - Fork 24
128 lines (116 loc) · 5.14 KB
/
deploy.yml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Deploy BOS-Workspace App Components
on:
workflow_call:
inputs:
cli-version:
required: false
description: "Version of BOS CLI to use for deploy (e.g. 0.3.0)"
type: string
default: "0.3.6"
bw-legacy:
required: false
description: "Flag to use legacy BOS Workspace deploy (e.g. 0.0.1-alpha.6)"
type: boolean
default : true
build-env:
required: false
description: "Environment to build workspace code to (e.g. staging)"
type: string
default: "mainnet"
deploy-env:
required: false
description: "Environment to deploy component code to (e.g. mainnet, testnet)"
type: string
default: "mainnet"
app-name:
required: true
description: "Workspace app name to deploy (from /apps directory)"
type: string
working-directory:
required: false
description: "Relative path to bos-workspace root"
type: string
default: "."
deploy-account-address:
required: true
description: "Account under which component code should be deployed"
type: string
signer-account-address:
required: true
description: "Account which will be used for signing deploy transaction, frequently the same as deploy-account-address"
type: string
signer-public-key:
required: true
description: "Public key for signing transactions in the format: `ed25519:<public_key>`"
type: string
secrets:
SIGNER_PRIVATE_KEY:
description: "Private key in `ed25519:<private_key>` format for signing transaction"
required: true
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Deploy Widgets
env:
BW_BUILD_ENV: ${{ inputs.build-env }}
BOS_DEPLOY_ENV: ${{ inputs.deploy-env }}
BOS_APP_NAME: ${{ inputs.app-name }}
WORKING_DIRECTORY: ${{ inputs.working-directory }}
BOS_DEPLOY_ACCOUNT_ID: ${{ inputs.deploy-account-address }}
BOS_SIGNER_ACCOUNT_ID: ${{ inputs.signer-account-address }}
BOS_SIGNER_PUBLIC_KEY: ${{ inputs.signer-public-key }}
BOS_SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install bos-cli-rs
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v${{ inputs.cli-version }}/bos-cli-installer.sh | sh
- name: Configure Lava Network RPC endpoint
run: |
mkdir -p ~/.config/near-cli
touch ~/.config/near-cli/config.toml
echo -e "credentials_home_dir = \"/home/runner/.near-credentials\"\n[network_connection.mainnet]\nnetwork_name = \"mainnet\"\nrpc_url = \"https://near.lava.build/\"\nwallet_url = \"https://app.mynearwallet.com/\"\nexplorer_transaction_url = \"https://nearblocks.io/txns/\"\n[network_connection.testnet]\nnetwork_name = \"testnet\"\nrpc_url = \"https://near-testnet.lava.build/\"\nwallet_url = \"https://wallet.testnet.near.org/\"\nexplorer_transaction_url = \"https://explorer.testnet.near.org/transactions/\"\nlinkdrop_account_id = \"testnet\"\nfaucet_url = \"https://helper.nearprotocol.com/account\"" > ~/.config/near-cli/config.toml
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install bos-workspace globally
run: |
if [ "${{ inputs.bw-legacy }}" = "true" ]; then
yarn global add [email protected]
else
yarn global add bos-workspace
fi
- name: Build and deploy the workspace
run: |
cd "$WORKING_DIRECTORY"
if [ "${{ inputs.bw-legacy }}" = "true" ]; then
BUILD_COMMAND="bos-workspace build"
BUILD_PATH="$WORKING_DIRECTORY/build/$BOS_APP_NAME"
else
if [ -f "bos.workspace.json" ]; then
echo "Found bos.workspace.json"
BUILD_COMMAND="bos-workspace ws build -n $BW_BUILD_ENV"
BUILD_PATH="$WORKING_DIRECTORY/build/apps/$BOS_APP_NAME"
elif [ -f "bos.config.json" ]; then
echo "Found bos.config.json"
BUILD_COMMAND="bos-workspace build -n $BW_BUILD_ENV"
BUILD_PATH="$WORKING_DIRECTORY/build"
else
echo "Neither bos.workspace.json nor bos.config.json found, aborting"
exit 1
fi
fi
echo "BUILD_COMMAND: $BUILD_COMMAND"
echo "BUILD_PATH: $BUILD_PATH"
$BUILD_COMMAND
cd $BUILD_PATH
# workaround because bos-cli-rs puts all widgets in src
if [ "${{ inputs.bw-legacy }}" = "false" ]; then
find src/widget/* -maxdepth 0 -exec mv -t ./src '{}' +
if [ -z "$(ls -A src/widget)" ]; then
rm -r src/widget
fi
fi
bos components deploy "$BOS_DEPLOY_ACCOUNT_ID" sign-as "$BOS_SIGNER_ACCOUNT_ID" network-config "$BOS_DEPLOY_ENV" sign-with-plaintext-private-key --signer-public-key "$BOS_SIGNER_PUBLIC_KEY" --signer-private-key "$BOS_SIGNER_PRIVATE_KEY" send