Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces a reusable git workflow #33

Merged
merged 8 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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"
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
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
signer-private-key:
required: true
description: "Private key in `ed25519:<private_key>` format for signing transaction"
type: string

jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Deploy Widgets
env:
BOS_DEPLOY_ENV: ${{ inputs.deploy-env }}
BOS_APP_NAME: ${{ inputs.app-name }}
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: ${{ inputs.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: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install bos-workspace globally
run: |
npm install -g bos-workspace

- name: Build the workspaces
run: |
bos-workspace build

- name: Deploy widgets
working-directory: ./build/${{ inputs.app-name }}
run: |
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
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache: yarn

- name: Install Dependencies
id: install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: yarn
registry-url: 'https://registry.npmjs.org'
cache: yarn
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
id: install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16
cache: yarn
cache: yarn

- name: Install Dependencies
id: install
Expand Down
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npm install -g bos-workspace

Then, create a new folder with the following structure:

```
```js
- apps
- {appname}
- bos.config.json
Expand Down Expand Up @@ -49,7 +49,6 @@ Commands:
```

> If the gateway can't fetch local components, try disabling brave shields or your adblock.

> If the commands don't work, try again using Node >=16

## Key Features
Expand Down Expand Up @@ -90,7 +89,7 @@ The build script will create a `data.json` file based on the `jsonc` and `txt` f

For instance, consider the following structure:

```
```js
- apps
- {appname}
- something.txt
Expand Down Expand Up @@ -124,3 +123,50 @@ To exclude files from the `data.json` file, add the `/*__@ignore__*/` comment to
The jsonc files will be passed through JSON.stringify before being stored in the `data.json` file, the build script will also remove all the comments and spaces from the jsonc files.
If you want to skip the JSON.stringify operation and keep the structure, add the following comment at the beginning of the file:
`/*__@noStringify__*/`

To use the [reusable workflow for deploying your apps](./.gitignore/workflows/deploy.yml) This workspace comes with a reusable workflow for deploying an app.

Here's the cleaned-up documentation in Markdown:

## Deploying Widgets through 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 'AppName' App Components to Mainnet

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

jobs:
deploy-mainnet:
uses: NEARBuilders/bos-workspace/.github/workflows/deploy.yml@main
with:
deploy-env: "mainnet" // environemnt to deploy to
app-name: "embeds" // app name with bos.config.json
deploy-account-address: ${{ vars.DEPLOY_ACCOUNT_ID }} // should match bos.config.json (TODO fix this)
signer-account-address: ${{ vars.SIGNER_ACCOUNT_ID }} // account to sign with
signer-public-key: ${{ vars.SIGNER_PUBLIC_KEY }}
signer-private-key: ${{ secrets.SIGNER_PRIVATE_KEY }}
```

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.

### 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"

- `app-name` (required): Workspace app name to deploy (from the /apps directory).

- `deploy-account-address` (required): Account under which component code should be deployed.

- `signer-account-address` (required): Account used for signing the deploy transaction, frequently the same as `deploy-account-address`.

- `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>`.
Loading