Skip to content
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
4 changes: 3 additions & 1 deletion .github/actions/create-or-update-secret/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ runs:
shell: bash
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
SECRET_NAME: ${{ inputs.secret_name }}
SECRET_VALUE: ${{ inputs.secret_value }}
run: |
gh secret set ${{ inputs.secret_name }} --body "${{ inputs.secret_value }}"
gh secret set "$SECRET_NAME" --body "$SECRET_VALUE"
69 changes: 48 additions & 21 deletions .github/actions/deploy-integrations/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Integrations
description: Deploys integrations

input:
inputs:
environment:
type: choice
description: 'Environment to deploy to'
Expand Down Expand Up @@ -42,56 +42,82 @@ runs:
shell: bash
run: |
script_path="./.github/scripts/ls-sentry-integrations.sh"
chmod +x $script_path
filter=$($script_path)
echo "::set-output name=filter::$filter"
chmod +x "$script_path"
filter=$("$script_path")
echo "filter=$filter" >> "$GITHUB_OUTPUT"
- name: Inject SourceMaps
shell: bash
run: pnpm -r --stream ${{ steps.list_sentry_integrations.outputs.filter }} exec sentry-cli sourcemaps inject .botpress/dist
env:
SENTRY_FILTER: ${{ steps.list_sentry_integrations.outputs.filter }}
run: |
# shellcheck disable=SC2086 # SENTRY_FILTER contains multiple space-separated -F flags that must be split into individual arguments
pnpm -r --stream $SENTRY_FILTER exec sentry-cli sourcemaps inject .botpress/dist
- name: Upload SourceMaps
shell: bash
run: pnpm -r --stream ${{ steps.list_sentry_integrations.outputs.filter }} exec sentry-cli sourcemaps upload --release=${{ github.sha }} --url-prefix '~' .botpress/dist
env:
SENTRY_AUTH_TOKEN: ${{ inputs.sentry_auth_token }}
SENTRY_ORG: botpress-rm
SENTRY_RELEASE: ${{ github.sha }}
SENTRY_FILTER: ${{ steps.list_sentry_integrations.outputs.filter }}
GITHUB_SHA: ${{ github.sha }}
run: |
# shellcheck disable=SC2086 # SENTRY_FILTER contains multiple space-separated -F flags that must be split into individual arguments
pnpm -r --stream $SENTRY_FILTER exec sentry-cli sourcemaps upload --release="$GITHUB_SHA" --url-prefix '~' .botpress/dist
- name: Deploys Integrations
shell: bash
env:
ENVIRONMENT: ${{ inputs.environment }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_FORCE: ${{ inputs.force }}
INPUT_DRY_RUN: ${{ inputs.dry_run }}
INPUT_EXTRA_FILTER: ${{ inputs.extra_filter }}
TOKEN_CLOUD_OPS_ACCOUNT: ${{ inputs.token_cloud_ops_account }}
CLOUD_OPS_WORKSPACE_ID: ${{ inputs.cloud_ops_workspace_id }}
SENTRY_RELEASE: ${{ github.sha }}
SENTRY_ENVIRONMENT: ${{ inputs.environment }}
shell: bash
run: |
api_url="${{ inputs.environment == 'staging' && 'https://api.botpress.dev' || 'https://api.botpress.cloud' }}"
if [ "$INPUT_ENVIRONMENT" = "staging" ]; then
api_url="https://api.botpress.dev"
else
api_url="https://api.botpress.cloud"
fi

# login

echo "### Logging in to $api_url ###"
pnpm bp login -y --api-url $api_url --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"
pnpm bp login -y --api-url "$api_url" --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"

# deploy

redeploy=${{ inputs.force == 'true' && 1 || 0 }}
dryrun="${{ inputs.dry_run == 'true' && '--dryRun' || '' }}"
is_dry_run=${{ inputs.dry_run == 'true' && 1 || 0 }}
all_filters="-F '{integrations/*}' ${{ inputs.extra_filter }}"
if [ "$INPUT_FORCE" = "true" ]; then
redeploy=1
else
redeploy=0
fi

if [ "$INPUT_DRY_RUN" = "true" ]; then
dryrun="--dryRun"
is_dry_run=1
else
dryrun=""
is_dry_run=0
fi

all_filters="-F '{integrations/*}' $INPUT_EXTRA_FILTER"
list_integrations_cmd="pnpm list $all_filters --json"
integration_paths=$(eval $list_integrations_cmd | jq -r "map(".path") | .[]")
integration_paths=$(eval "$list_integrations_cmd" | jq -r 'map(".path") | .[]')

for integration_path in $integration_paths; do
integration=$(basename $integration_path)
exists=$(./.github/scripts/integration-exists.sh $integration)
integration=$(basename "$integration_path")
exists=$(./.github/scripts/integration-exists.sh "$integration")

base_command="bp deploy -v -y --noBuild --visibility public --allowDeprecated $dryrun"

upload_sandbox_scripts=false
if [ $exists -eq 0 ]; then
if [ "$exists" -eq 0 ]; then
echo -e "\nDeploying integration: ### $integration ###\n"
pnpm retry -n 2 -- pnpm -F "{integrations/$integration}" -c exec -- "$base_command"
upload_sandbox_scripts=true
elif [ $redeploy -eq 1 ]; then
elif [ "$redeploy" -eq 1 ]; then
echo -e "\nRe-deploying integration: ### $integration ###\n"
pnpm retry -n 2 -- pnpm -F "{integrations/$integration}" -c exec -- "$base_command"
upload_sandbox_scripts=true
Expand All @@ -100,10 +126,11 @@ runs:
fi

# upload sandbox scripts
integration_implements_sandbox=$(./.github/scripts/integration-implements-sandbox.sh $integration)
if [ $integration_implements_sandbox == "true" ] && [ $upload_sandbox_scripts == "true" ] && [ $is_dry_run -eq 0 ]; then
integration_implements_sandbox=$(./.github/scripts/integration-implements-sandbox.sh "$integration")
if [ "$integration_implements_sandbox" = "true" ] && [ "$upload_sandbox_scripts" = "true" ] && [ "$is_dry_run" -eq 0 ]; then
echo -e "\nUploading integration sandbox scripts\n"
base_upload_command="uploadSandboxScripts --apiUrl=$api_url --workspaceId=$CLOUD_OPS_WORKSPACE_ID --token=$TOKEN_CLOUD_OPS_ACCOUNT --userEmail=cloud-ops@botpress.com"
# shellcheck disable=SC2086 # base_upload_command contains multiple space-separated arguments
pnpm retry -n 2 -- pnpm -F "{integrations/$integration}" run -- $base_upload_command
fi
done
33 changes: 22 additions & 11 deletions .github/actions/deploy-interfaces/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,46 @@ runs:
using: 'composite'
steps:
- name: Deploys Interfaces
shell: bash
env:
ENVIRONMENT: ${{ inputs.environment }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_FORCE: ${{ inputs.force }}
INPUT_EXTRA_FILTER: ${{ inputs.extra_filter }}
TOKEN_CLOUD_OPS_ACCOUNT: ${{ inputs.token_cloud_ops_account }}
CLOUD_OPS_WORKSPACE_ID: ${{ inputs.cloud_ops_workspace_id }}
shell: bash
run: |
api_url="${{ inputs.environment == 'staging' && 'https://api.botpress.dev' || 'https://api.botpress.cloud' }}"
if [ "$INPUT_ENVIRONMENT" = "staging" ]; then
api_url="https://api.botpress.dev"
else
api_url="https://api.botpress.cloud"
fi

# login

echo "### Logging in to $api_url ###"
pnpm bp login -y --api-url $api_url --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"
pnpm bp login -y --api-url "$api_url" --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"

# deploy

redeploy=${{ inputs.force == 'true' && 1 || 0 }}
all_filters="-F '{interfaces/*}' ${{ inputs.extra_filter }}"
if [ "$INPUT_FORCE" = "true" ]; then
redeploy=1
else
redeploy=0
fi

all_filters="-F '{interfaces/*}' $INPUT_EXTRA_FILTER"
list_interfaces_cmd="pnpm list $all_filters --json"
interface_paths=$(eval $list_interfaces_cmd | jq -r "map(".path") | .[]")
interface_paths=$(eval "$list_interfaces_cmd" | jq -r 'map(".path") | .[]')

for interface_path in $interface_paths; do
interface=$(basename $interface_path)
exists=$(./.github/scripts/interface-exists.sh $interface)
interface=$(basename "$interface_path")
exists=$(./.github/scripts/interface-exists.sh "$interface")

base_command="bp deploy -v -y --visibility public"
if [ $exists -eq 0 ]; then
if [ "$exists" -eq 0 ]; then
echo -e "\nDeploying interface: ### $interface ###\n"
pnpm retry -n 2 -- pnpm -F "{interfaces/$interface}" -c exec -- "$base_command"
elif [ $redeploy -eq 1 ]; then
elif [ "$redeploy" -eq 1 ]; then
echo -e "\nRe-deploying interface: ### $interface ###\n"
pnpm retry -n 2 -- pnpm -F "{interfaces/$interface}" -c exec -- "$base_command"
else
Expand Down
35 changes: 23 additions & 12 deletions .github/actions/deploy-plugins/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,47 @@ runs:
using: 'composite'
steps:
- name: Deploys Plugins
shell: bash
env:
ENVIRONMENT: ${{ inputs.environment }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_FORCE: ${{ inputs.force }}
INPUT_EXTRA_FILTER: ${{ inputs.extra_filter }}
TOKEN_CLOUD_OPS_ACCOUNT: ${{ inputs.token_cloud_ops_account }}
CLOUD_OPS_WORKSPACE_ID: ${{ inputs.cloud_ops_workspace_id }}
shell: bash
run: |
api_url="${{ inputs.environment == 'staging' && 'https://api.botpress.dev' || 'https://api.botpress.cloud' }}"
if [ "$INPUT_ENVIRONMENT" = "staging" ]; then
api_url="https://api.botpress.dev"
else
api_url="https://api.botpress.cloud"
fi

# login

echo "### Logging in to $api_url ###"
pnpm bp login -y --api-url $api_url --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"
pnpm bp login -y --api-url "$api_url" --workspaceId "$CLOUD_OPS_WORKSPACE_ID" --token "$TOKEN_CLOUD_OPS_ACCOUNT"

# deploy

redeploy=${{ inputs.force == 'true' && 1 || 0 }}
all_filters="-F '{plugins/*}' ${{ inputs.extra_filter }}"
if [ "$INPUT_FORCE" = "true" ]; then
redeploy=1
else
redeploy=0
fi

all_filters="-F '{plugins/*}' $INPUT_EXTRA_FILTER"
list_plugins_cmd="pnpm list $all_filters --json"
plugin_paths=$(eval $list_plugins_cmd | jq -r "map(".path") | .[]")
plugin_paths=$(eval "$list_plugins_cmd" | jq -r 'map(".path") | .[]')

for plugin_path in $plugin_paths; do
plugin=$(basename $plugin_path)
exists=$(./.github/scripts/plugin-exists.sh $plugin)
plugin=$(basename "$plugin_path")
exists=$(./.github/scripts/plugin-exists.sh "$plugin")

base_command="bp deploy -v -y --visibility public"
if [ $exists -eq 0 ]; then

if [ "$exists" -eq 0 ]; then
echo -e "\nDeploying plugin: ### $plugin ###\n"
pnpm retry -n 2 -- pnpm -F "{plugins/$plugin}" -c exec -- "$base_command"
elif [ $redeploy -eq 1 ]; then
elif [ "$redeploy" -eq 1 ]; then
echo -e "\nRe-deploying plugin: ### $plugin ###\n"
pnpm retry -n 2 -- pnpm -F "{plugins/$plugin}" -c exec -- "$base_command"
else
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/docker-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ runs:
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
run: |
aws --version
aws ecr create-repository --repository-name $ECR_REPOSITORY || true
aws ecr create-repository --repository-name "$ECR_REPOSITORY" || true
aws ssm get-parameter --name '/cloud/container-registry/ecr-policy-document' --query 'Parameter.Value' | jq -r > repository-policy.json
aws ecr set-repository-policy --repository-name $ECR_REPOSITORY --policy-text file://repository-policy.json &> /dev/null
aws ecr set-repository-policy --repository-name "$ECR_REPOSITORY" --policy-text file://repository-policy.json &> /dev/null

- name: Set up Depot CLI
uses: depot/setup-action@v1
Expand Down
5 changes: 4 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ runs:
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
env:
BP_VERBOSE: 'true'
run: pnpm turbo run build ${{ inputs.extra_filters }}
EXTRA_FILTERS: ${{ inputs.extra_filters }}
run: |
# shellcheck disable=SC2086 # EXTRA_FILTERS contains multiple space-separated filter arguments
pnpm turbo run build $EXTRA_FILTERS
11 changes: 6 additions & 5 deletions .github/scripts/integration-exists.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: integration name is not provided" >&2
exit 1
fi
integration=$1

integration_path="integrations/$integration"
integration_def=$(pnpm bp read --work-dir $integration_path --json)
integration_def=$(pnpm bp read --work-dir "$integration_path" --json)

name=$(echo $integration_def | jq -r ".name")
version=$(echo $integration_def | jq -r ".version")
name=$(echo "$integration_def" | jq -r ".name")
version=$(echo "$integration_def" | jq -r ".version")

exists=$(pnpm bp integrations ls --name $name --version-number $version --json | jq '[ .[] | select(.public) ] | length') # 0 if not exists
echo $exists
exists=$(pnpm bp integrations ls --name "$name" --version-number "$version" --json | jq '[ .[] | select(.public) ] | length') # 0 if not exists
echo "$exists"
3 changes: 2 additions & 1 deletion .github/scripts/integration-implements-sandbox.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: integration name is not provided" >&2
exit 1
Expand All @@ -12,4 +13,4 @@ if [ -f "$sandbox_script" ]; then
has_sandbox=true
fi

echo $has_sandbox
echo "$has_sandbox"
11 changes: 6 additions & 5 deletions .github/scripts/interface-exists.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: interface name is not provided" >&2
exit 1
fi
interface=$1

interface_path="interfaces/$interface"
interface_def=$(pnpm bp read --work-dir $interface_path --json)
interface_def=$(pnpm bp read --work-dir "$interface_path" --json)

name=$(echo $interface_def | jq -r ".name")
version=$(echo $interface_def | jq -r ".version")
name=$(echo "$interface_def" | jq -r ".name")
version=$(echo "$interface_def" | jq -r ".version")

command="pnpm bp interfaces get \"$name@$version\" --json >/dev/null 2>&1"
exists=$(eval $command && echo 1 || echo 0)
echo $exists
exists=$(eval "$command" && echo 1 || echo 0)
echo "$exists"
7 changes: 4 additions & 3 deletions .github/scripts/ls-sentry-integrations.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
sentry_integrations=( $(ls integrations/*/.sentryclirc) )
#!/bin/bash
mapfile -t sentry_integrations < <(ls integrations/*/.sentryclirc)

filter=""

for sentry_integration in "${sentry_integrations[@]}";
do
actual_integration=$(echo $sentry_integration | sed 's/\.sentryclirc//g')
actual_integration="${sentry_integration//\.sentryclirc/}"
filter="-F ./$actual_integration $filter"
done

echo $filter
echo "$filter"
11 changes: 6 additions & 5 deletions .github/scripts/plugin-exists.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: plugin name is not provided" >&2
exit 1
fi
plugin=$1

plugin_path="plugins/$plugin"
plugin_def=$(pnpm bp read --work-dir $plugin_path --json)
plugin_def=$(pnpm bp read --work-dir "$plugin_path" --json)

name=$(echo $plugin_def | jq -r ".name")
version=$(echo $plugin_def | jq -r ".version")
name=$(echo "$plugin_def" | jq -r ".name")
version=$(echo "$plugin_def" | jq -r ".version")

command="pnpm bp plugins get \"$name@$version\" --json >/dev/null 2>&1"
exists=$(eval $command && echo 1 || echo 0)
echo $exists
exists=$(eval "$command" && echo 1 || echo 0)
echo "$exists"
Loading
Loading