Skip to content

Commit

Permalink
deploy workflow tool updated; cli adjustment; new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Mar 8, 2024
1 parent e4802bf commit 8b48300
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 17 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy BOS dApp (built using Alem)
name: Deploy BOS DApp (built using Alem)
on:
workflow_call:
inputs:
Expand All @@ -12,22 +12,14 @@ on:
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 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"
description: "Account under which component code should be deployed and which will be used for signing deploy transaction"
type: string
signer-public-key:
required: true
Expand All @@ -45,7 +37,6 @@ jobs:
env:
DEPLOY_ENV: ${{ inputs.deploy-env }}
WORKSPACE_DIRECTORY: ${{ inputs.working-directory }}
DEPLOY_ACCOUNT_ID: ${{ inputs.deploy-account-address }}
SIGNER_ACCOUNT_ID: ${{ inputs.signer-account-address }}
SIGNER_PUBLIC_KEY: ${{ inputs.signer-public-key }}
SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }}
Expand Down Expand Up @@ -82,4 +73,4 @@ jobs:
run: |
pwd
cd "$WORKSPACE_DIRECTORY/build"
bos components deploy "$DEPLOY_ACCOUNT_ID" sign-as "$SIGNER_ACCOUNT_ID" network-config "$DEPLOY_ENV" sign-with-plaintext-private-key --signer-public-key "$SIGNER_PUBLIC_KEY" --signer-private-key "$SIGNER_PRIVATE_KEY" send
bos components deploy "$SIGNER_ACCOUNT_ID" sign-as "$SIGNER_ACCOUNT_ID" network-config "$DEPLOY_ENV" sign-with-plaintext-private-key --signer-public-key "$SIGNER_PUBLIC_KEY" --signer-private-key "$SIGNER_PRIVATE_KEY" send
57 changes: 57 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Além CLI

Além has its own command system.

### Commands

```bash
Usage: alem [options] [command]

Options:
-V, --version output the version number
-h, --help display help for command

Commands:
dev Run the development server
build Build the project
deploy Deploy the project
upload-data Upload data to SocialDB (app name, description, icon, tags, etc)
```

#### Command: `dev`

Run the development server with various options:

```bash
Usage: alem dev [options]

Options:
-p, --port <port> Port to run the server on (default: 8080)
-no-open Disable opening the browser (default: false)
```

#### Command: `build`

Build the project:

```bash
Usage: bos build
```

This will output valid widget code to the `/build` directory.

#### Command: `deploy`

Deploy the project to Near BOS:

```bash
Usage: bos deploy
```

#### Command: `upload-data`

Upload data to SocialDB. This is going to use the data provided by `bos.config.json` file. The content represents the app's details like `name, description, icon, tags, etc`. You can update this information manually by going to the widget metadata tab using the [Near Sandbox](https://near.org/sandbox).

```bash
Usage: bos upload-data
```
37 changes: 37 additions & 0 deletions docs/deploying-with-github-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Deploying App With GitHub Actions

To deploy widgets on push to branch, create a GitHub Actions workflow file in your repository, e.g., `.github/workflows/deploy-embeds-mainnet.yml`, and configure it as follows:

```yaml
name: Deploy DApp to Mainnet

on:
push:
branches: [main] # branch for trigger

jobs:
deploy-mainnet:
uses: wpdas/alem/.github/workflows/deploy.yml@main
with:
deploy-env: "mainnet" # environemnt to deploy to
signer-account-address: <SIGNER_ACCOUNT_ID> # account to sign with (should match bos.config.json > account)
signer-public-key: <SIGNER_PUBLIC_KEY>
secrets:
SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} # must be inside the github repo secrets
```
Adjust the workflow as needed, then configure your variables + secrets on GitHub Settings -> Actions -> secrets & variables. Use [near-cli-rs](https://github.com/near/near-cli-rs) for generating keypairs. You can also login using Near CLI and check the keypairs locally.
### Workflow Inputs
The workflow accepts the following inputs:
- `cli-version` (optional): Version of BOS CLI to use for deployment (e.g., 0.3.0). Default: "0.3.6"

- `deploy-env` (optional): Environment to deploy component code to (e.g., mainnet, testnet). Default: "mainnet"

- `signer-account-address` (required): Account under which component code should be deployed and used for signing the deploy transaction.

- `signer-public-key` (required): Public key for signing transactions in the format: `ed25519:<public_key>`.

- `signer-private-key` (required): Private key for signing transactions in the format: `ed25519:<private_key>`.
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function run() {
.command("dev")
.description("Run the development server")
.option("-p, --port <port>", "Port to run the server on", "8080")
.option("-no-gateway", "Disable the gateway", false)
.option("-no-hot", "Disable hot reloading", false)
// .option("-no-gateway", "Disable the gateway", false)
// .option("-no-hot", "Disable hot reloading", false)
.option("-no-open", "Disable opening the browser", false)
.action((opts) => {
dev(opts).catch((err) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ async function dev(opts) {
// Start serving the development JSON
const { io } = await serveDevJson({
port: opts.port || 3000,
useGateway: !opts.NoGateway,
useSocket: !opts.NoHot,
// useGateway: !opts.NoGateway,
// useSocket: !opts.NoHot,
useGateway: true,
useSocket: true,
useOpen: !opts.NoOpen,
}).catch((err) => {
log.error(err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alem",
"description": "Create web3 applications for NEAR BOS with a focus on performance while using concepts that are based on ReactJS.",
"version": "0.0.1-alpha.11",
"version": "0.0.1-alpha.12",
"main": "main.js",
"types": "index.d.ts",
"author": "Wenderson Pires - wendersonpires.near",
Expand Down

0 comments on commit 8b48300

Please sign in to comment.